klibc-bot for Ben Hutchings
2022-Oct-01 23:45 UTC
[klibc] [klibc:master] zalloc: Fix infinite recursion with Clang 14
Commit-ID: eec04ea422f69d09288da8475c82e030c0300a60 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=eec04ea422f69d09288da8475c82e030c0300a60 Author: Ben Hutchings <ben at decadent.org.uk> AuthorDate: Sun, 2 Oct 2022 00:23:26 +0200 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sun, 2 Oct 2022 00:27:43 +0200 [klibc] zalloc: Fix infinite recursion with Clang 14 zalloc() calls malloc() followed by memset(), which Clang 14 optimises to a call to calloc(). But our calloc() calls zalloc(), so this results in recursion until the stack is exhausted. Use the option -fno-builtin-malloc to inhibit this optimisation for zalloc.c. Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/klibc/Kbuild | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild index 973b0c81..eb13a70e 100644 --- a/usr/klibc/Kbuild +++ b/usr/klibc/Kbuild @@ -89,6 +89,10 @@ endif KLIBCCFLAGS_sprintf.o += $(call cc-option,-Wno-format-truncation, ) KLIBCCFLAGS_vsprintf.o += $(call cc-option,-Wno-format-truncation, ) +# Clang 14 optimises zalloc() to recursively call calloc(), without +# this option +KLIBCCFLAGS_zalloc.o += $(call cc-option,-fno-builtin-malloc, ) + # sigsuspend.c includes <klibc/havesyscall.h> generated by syscalls/ # build, so require that to build first $(obj)/sigsuspend.o: $(obj)/syscalls/klib.list