-
Notifications
You must be signed in to change notification settings - Fork 3k
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
malloc unexpected behaviour on GCC_ARM compiler #5386
Comments
@maciejbocianski we implement |
@0xc0170 @bulislaw @c1728p9 Below output from "Test program 2" run on NUCLEO_F070RB (program code in issue description) We can see that on The question is if we can force
[Mirrored to Jira] |
The behavior I saw when I looked at this a while back was that calls to
If the interrupt stack was moved to come before the heap then the end of the heap would be on a 4k boundary, and in theory you would make use of the whole heap. I'm not sure what it would take to make this change though. |
other question is why first allocation likely performed by |
@maciejbocianski the first allocation of 1140B brings the heap limit to a 4k boundary |
Looks like by this 4kB alignment we lose 3kB of heap, what is huge problem for platforms with small RAM (we can utilize not much more than 2kB at least for NUCLEO_F070RB) Regarding interrupt stack as it can be read here #1561 it was intentionally put on the RAM end. |
Any update about this issue ? |
Right now I don't think we have a path forward, more investigation is needed. |
@bulislaw @jeromecoutant @maciejbocianski @c1728p9 Has anyone continued to look at this? Is this still a major bug? |
You could upgrade to GCC ARM Embedded 6-2017-q1-update or newer and link with newlib-nano instead of the full newlib Standard C Library. That version of newlib-nano synchronizes multithreaded access to the heap. newlib-nano doesn't do this 4k paging as it is the version of newlib meant for small memory devices like this. |
This means that the restriction to forbid thread with nano gcc lib doesn't exist anymore ? [Mirrored to Jira] |
@cmonr I have a task on me to look into it. |
Newlib nano doesn't have thread safe file access so even with a protected heap, it may still be unsafe to use. |
Internal Jira reference: https://jira.arm.com/browse/IOTCORE-156 |
Malloc unaligned behavior for GCC_ARM cannot be fixed. GCC_ARM toolchain expects heap to be 4K aligned. If heap is not aligned at 4K boundary allocation will fail. |
Are you still tracking that somehow, since this issue is now closed? |
Yes it will be tracked internally |
Description
Bug
Target
all
Toolchain:
GCC_ARM
Toolchain version:
gcc version 6.3.1 20170620 (release) [ARM/embedded-6-branch revision 249437] (GNU Tools for ARM Embedded Processors 6-2017-q2-update)
mbed-cli version:
1.2.0
mbed-os sha:
38ba693
Expected behavior
When try to allocate more memory than heap can handle we get NULL from malloc and further allocations (within heap size) work fine
Actual behavior
When try to allocate more memory than heap can handle we get NULL from malloc and any further allocation (within heap size) return NULL
Steps to reproduce
Compile and run below code
Program find maximum memory which malloc can allocate
Output from NUCLEO_F070RB
Test program 2
Test program 2 additional changes in platform/mbed_retarget.cpp
The text was updated successfully, but these errors were encountered: