mirror of https://github.com/ARMmbed/mbed-os.git
The commit 84d0689 "Nano-malloc: Fix for unwanted external heap fragmentation" from newlib 4.1.0 introduced several optimizations, one of which is as follows: When the last chunk in the free list is smaller than requested, nano_malloc() calls sbrk(0) to see if the heap's current head is adjacent to this chunk, and if so it asks sbrk() to allocate the difference in bytes only and expands the current chunk. This doesn't work if the heap consists of non-contiguous regions. sbrk(0) returns the the current region's head if the region has any remaining capacity. But if this capacity is not enough for the second (non-trivial) call to sbrk() described above, allocation will happen from the next region if available. Expanding the current chunk won't work and will result in a segmentation fault. So this optimization needs to be reverted in order to bring back compatibility with non-contiguous heaps. Before the next version of newlib becomes available and gets updated in the GCC Arm Embedded Toolchain, we work around this issue by including the fix in Mbed OS. The linker prioritizes malloc() from the project to the one from the toolchain. |
||
---|---|---|
.. | ||
TARGET_CORTEX_A/TOOLCHAIN_IAR | ||
TARGET_CORTEX_M | ||
minimal-printf | ||
ATCmdParser.cpp | ||
CMakeLists.txt | ||
CThunkBase.cpp | ||
CriticalSectionLock.cpp | ||
DeepSleepLock.cpp | ||
FileBase.cpp | ||
FileHandle.cpp | ||
FilePath.cpp | ||
FileSystemHandle.cpp | ||
LocalFileSystem.cpp | ||
Stream.cpp | ||
SysTimer.cpp | ||
mbed_alloc_wrappers.cpp | ||
mbed_application.c | ||
mbed_assert.c | ||
mbed_atomic_impl.c | ||
mbed_board.c | ||
mbed_crash_data_offsets.h | ||
mbed_critical.c | ||
mbed_error.c | ||
mbed_error_hist.c | ||
mbed_interface.c | ||
mbed_mem_trace.cpp | ||
mbed_mktime.c | ||
mbed_mpu_mgmt.c | ||
mbed_os_timer.cpp | ||
mbed_poll.cpp | ||
mbed_power_mgmt.c | ||
mbed_retarget.cpp | ||
mbed_rtc_time.cpp | ||
mbed_sdk_boot.c | ||
mbed_semihost_api.c | ||
mbed_stats.c | ||
mbed_thread.cpp | ||
mbed_wait_api_no_rtos.c | ||
newlib_nano_malloc_workaround.c |