Skip to content

Commit 59ddae3

Browse files
stephanosioantmak
authored andcommitted
xtensa: Use default malloc alignment of 8
The current malloc implementation has a bug in which the first malloc call may fail if MALLOC_ALIGNMENT is 16 and the requested block size is such that malloc invokes sbrk with the heap expansion size that causes the resulting heap address to fall on a page boundary. sys/config.h was defining the minimum MALLOC_ALIGNMENT for the Xtensa architecture as 16, and this caused the first malloc call to fail on the Xtensa platforms in some rare cases that satisfy the conditions described above (see zephyrproject-rtos/zephyr#38258). Since the Xtensa architecture in itself does not require the malloc alignment of 16, remove MALLOC_ALIGNMENT definition and use the default alignment of 8 for all Xtensa platforms. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
1 parent 022fa47 commit 59ddae3

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

newlib/libc/include/sys/config.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@
194194
#endif
195195

196196
#ifdef __XTENSA__
197-
#include <xtensa/config/core-isa.h>
198-
#define MALLOC_ALIGNMENT ((XCHAL_DATA_WIDTH) < 16 ? 16 : (XCHAL_DATA_WIDTH))
199197
/* Espressif-specific: shrink the default fd buffer size */
200198
#define __BUFSIZ__ 128
201199
#ifndef __DYNAMIC_REENT__

0 commit comments

Comments
 (0)