Can't malloc the last 4KB of the heap #264

Closed
opened 2021-03-17 14:10:08 -05:00 by MichaelBell · 5 comments
MichaelBell commented 2021-03-17 14:10:08 -05:00 (Migrated from github.com)

malloc won't allocate the last 4KB of available heap (addresses in 2003F000- 20040000). A simple test program is here: https://gist.github.com/MichaelBell/a13513a483a07a41c5b74e8458fba51d

I believe the problem is _sbrk should allow heap_end to be moved up to __StackLimit. I've got a commit which appears to fix the issue but I'm not sufficiently familiar with how this is meant to work to know whether that's the correct approach.

malloc won't allocate the last 4KB of available heap (addresses in 2003F000- 20040000). A simple test program is here: https://gist.github.com/MichaelBell/a13513a483a07a41c5b74e8458fba51d I believe the problem is _sbrk should allow heap_end to be moved up to __StackLimit. I've got a [commit which appears to fix the issue](https://github.com/MichaelBell/pico-sdk/commit/4d84592bef7cdeb2b1f4081ca528875c14fa447b) but I'm not sufficiently familiar with how this is meant to work to know whether that's the correct approach.
kilograham commented 2021-03-17 19:56:05 -05:00 (Migrated from github.com)

yes your fix looks sensible... it is all a bit of a hack (the OPTIMISTIC_SBRK thing) since SBRK is being called for 4K but you are not giving it 4K...

yes your fix looks sensible... it is all a bit of a hack (the OPTIMISTIC_SBRK thing) since SBRK is being called for 4K but you are not giving it 4K...
MichaelBell commented 2021-03-18 07:22:40 -05:00 (Migrated from github.com)

Cool, I've made a pull request with a brief explanation of what it does.

Cool, I've made a pull request with a brief explanation of what it does.
kilograham commented 2021-03-21 19:11:56 -05:00 (Migrated from github.com)

can you please rebase onto develop-1.1.1

can you please rebase onto develop-1.1.1
MichaelBell commented 2021-03-22 13:44:04 -05:00 (Migrated from github.com)

I've rebased and updated the PR.

I've rebased and updated the PR.
kilograham commented 2021-03-24 09:36:49 -05:00 (Migrated from github.com)

merged

merged
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#264
No description provided.