Skip to content

Tighten GCC 2-region _sbrk #11572

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

Merged
merged 1 commit into from
Oct 3, 2019
Merged

Tighten GCC 2-region _sbrk #11572

merged 1 commit into from
Oct 3, 2019

Conversation

kjbracey
Copy link
Contributor

Description

When moving to the second heap region due to overflowing the first region, the _sbrk implementation assumed the allocation would fit in the second region, and didn't check for that overflowing too.

Problem revealed in stats_heap test with GCC 8 on K64F - the allocation attempt for 1GiB crashed, as _sbrk indicated 1GiB was available at the start of the second region.

Presumably older versions of newlib fault that allocation attempt before passing to _sbrk.

While there, adjust the code to not use a separate static bool, saving RAM. We can track with just one pointer, as order of the two regions is fixed, and already relied on by newlib.

Pull request type

[X] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@OPpuolitaival, @evedon

When moving to the second heap region due to overflowing the first
region, the `_sbrk` implementation assumed the allocation would fit in
the second region, and didn't check for that overflowing too.

Problem revealed in `stats_heap` test with GCC 8 on K64F - the allocation
attempt for 1GiB crashed, as `_sbrk` indicated 1GiB was available at the
start of the second region.
second region.

Presumably older versions of newlib fault that allocation attempt before
passing to `_sbrk`.

While there, adjust the code to not use a separate static `bool`, saving
RAM. We can track with just one pointer, as order of the two regions is
fixed, and already relied on by newlib.
@ciarmcom ciarmcom requested review from evedon, OPpuolitaival and a team September 26, 2019 15:00
@ciarmcom
Copy link
Member

@kjbracey-arm, thank you for your changes.
@OPpuolitaival @evedon @ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 30, 2019

CI started

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 1, 2019

Built has not finished, I aborted and restarted it

@mbed-ci
Copy link

mbed-ci commented Oct 1, 2019

Test run: FAILED

Summary: 1 of 11 test jobs failed
Build number : 2
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_cloud-client-test

Copy link
Member

@bulislaw bulislaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally should be split between two commits.

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

Successfully merging this pull request may close these issues.

8 participants