Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate and fix heap allocation test failure with GNU Arm Embedded Toolchain 10.3-2021.07 #15023

Closed
Tracked by #14967
LDong-Arm opened this issue Aug 25, 2021 · 1 comment · Fixed by #15045
Closed
Tracked by #14967

Comments

@LDong-Arm
Copy link
Contributor

No description provided.

@LDong-Arm
Copy link
Contributor Author

There's a bug in newlib-nano 4.1.0:

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 srbk(0) to see if the heap's current head is adjacent to this chunk, and if so it asks srbk() for the difference in bytes only and expands the current chunk.

This doesn't work if the heap consists of non-contiguous regions. srbk(0) returns the the current region's head if the latter has any remaining capacity. But if this capacity is not enough for the second (non-trivial) call to srbk() 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants