This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 38e8f5088 baselibc: Prevent calloc recursion
38e8f5088 is described below
commit 38e8f5088e64b928ed6731be7ee10f2f3b434311
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Tue Oct 4 12:55:08 2022 +0200
baselibc: Prevent calloc recursion
When optimization is above O1 compilers recognizes
sequences:
p = malloc(n);
memset(p, 0, n);
and turns them into calloc calls.
Unfortunately this sequence is actually in baselibc
implementation of calloc so compiler just optimizes this
sequence and calls calloc recursively or jumps to the beginning
resulting in infinite loops.
To break this circle baselibc is build with option
-fno-builtin-malloc
---
libc/baselibc/pkg.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libc/baselibc/pkg.yml b/libc/baselibc/pkg.yml
index 1ec133b1e..861a4a9ef 100644
--- a/libc/baselibc/pkg.yml
+++ b/libc/baselibc/pkg.yml
@@ -30,3 +30,6 @@ pkg.req_apis:
pkg.init.BASELIBC_THREAD_SAFE_HEAP_ALLOCATION:
baselibc_init: 0
+
+pkg.cflags:
+ - -fno-builtin-malloc