Skip to content

Heap and main thread stack checking #2367

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

Closed
wants to merge 9 commits into from

Conversation

c1728p9
Copy link
Contributor

@c1728p9 c1728p9 commented Aug 4, 2016

Turn on main thread stack checking. This PR is on top of #2319

@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 4, 2016

/morph test

@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 4, 2016

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=GCC_ARM,ARM,IAR
TARGETS=K64F,NRF51_DK,NRF51_MICROBIT,NUCLEO_F411RE

@mbed-bot
Copy link

mbed-bot commented Aug 4, 2016

[Build 769]
SUCCESS: Building succeeded and tests were run! Be sure to check the test results

@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 4, 2016

/morph test

@mbed-bot
Copy link

mbed-bot commented Aug 4, 2016

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 599

Test failed!

@mbed-bot
Copy link

mbed-bot commented Aug 4, 2016

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 601

Test failed!

@bridadan
Copy link
Contributor

bridadan commented Aug 4, 2016

@c1728p9 Test looks ok, false failure 👍

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 8, 2016

Commit 4055d08 looks good. How did you test this?

@c1728p9 c1728p9 mentioned this pull request Aug 8, 2016
@c1728p9 c1728p9 force-pushed the main_thread_stack_checking branch from 4055d08 to 09c98a3 Compare August 8, 2016 21:21
@c1728p9 c1728p9 changed the title Main thread stack checking Heap and main thread stack checking Aug 8, 2016
@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 8, 2016

/morph test

@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 8, 2016

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=GCC_ARM,ARM,IAR
TARGETS=K64F,NRF51_DK,NRF51_MICROBIT,NUCLEO_F411RE

@mbed-bot
Copy link

mbed-bot commented Aug 8, 2016

[Build 783]
SUCCESS: Building succeeded and tests were run! Be sure to check the test results

@mbed-bot
Copy link

mbed-bot commented Aug 8, 2016

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 614

Build failed!

@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 8, 2016

/morph test

@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 8, 2016

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=GCC_ARM,ARM,IAR
TARGETS=K64F,NRF51_DK,NRF51_MICROBIT,NUCLEO_F411RE

@@ -714,3 +726,34 @@ extern "C" void __env_unlock( struct _reent *_r )
#endif

} // namespace mbed

void* operator new(std::size_t count)
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick:

void* operator new(std::size_t count)
void *operator new(std::size_t count)

void* operator new[](std::size_t count)
void *operator new[](std::size_t count)

void operator delete(void* ptr)
void operator delete(void *ptr)

void operator delete[](void* ptr)
void operator delete[](void *ptr)

@mbed-bot
Copy link

mbed-bot commented Aug 8, 2016

[Build 785]
SUCCESS: Building succeeded and tests were run! Be sure to check the test results

@mbed-bot
Copy link

mbed-bot commented Aug 9, 2016

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 616

Test failed!

@c1728p9 c1728p9 force-pushed the main_thread_stack_checking branch from ff8f789 to 66bc6a2 Compare August 9, 2016 03:07
@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 9, 2016

/morph test

@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 9, 2016

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=GCC_ARM,ARM,IAR
TARGETS=K64F,NRF51_DK,NRF51_MICROBIT,NUCLEO_F411RE

@mbed-bot
Copy link

mbed-bot commented Aug 9, 2016

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 617

Test failed!

@mbed-bot
Copy link

mbed-bot commented Aug 9, 2016

[Build 787]
SUCCESS: Building succeeded and tests were run! Be sure to check the test results

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 9, 2016

Please refrain from adding non-relevant commits (targets changes), that could be a separate patch. Can you please fix formatting of * (void * pointer -> void *pointer).

@@ -0,0 +1,218 @@
#include <stdio.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

this file should contain license on the top, please add it

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 9, 2016

+1 for consolidating stack and heap, and enabling checking for the main thread.

Tests fail for cfstore (2 errors there, for 2 targets and only GCC_ARM), I dont think its related to this changeset. @simonqhughes Any pointers?
Edit: looks like it is, Russ please provide some info what needs to be done

@bridadan
Copy link
Contributor

bridadan commented Aug 9, 2016

Please refrain from adding non-relevant commits (targets changes), that could be a separate patch.

@0xc0170 Pretty sure he made that target patch so the test would pass (it previously failed due to the other changes in this PR). So I think that's justified.

Set well defined limits for the heap and configure GCC and ARMCC to
correctly check these. IAR already correctly checked its heap.

This also statically declares the main thread stack in IAR so the
linker is responsible for its placement. This must be statically
declared since the majority of IAR .icf files make no guarantees
where free space is located.

For GCC_ARM and ARM the main thread stack is placed inside the heap
and the heap size is adjusted to account for this.
c1728p9 and others added 8 commits August 9, 2016 14:36
Decrease the main stack size for the nrf51 so there is more heap
space available.
When new or new[] fails to allocate space trigger an error.
With the latest K64F linker file the initial stack is out of sync
with INITIAL_SP when uVisor is not present. This patch removes
the incorrect declaration.
Since the heap and stack are no longer shared, stack checking on the
main thread can be turned back on. This allows stack overflows on the
main thread to be caught quickly.
Test the following components of the heap and stacks:
-Heap, Interrupt stack and thread stack are at the expected locations
-Entire range of main stack can be used without corrupting memory
-Entire heap can be used
-Heap limit is properly enforced and returns NULL when out of
  of memory
Decrease the interrupt stack of the NUC472 from 12KB to 8KB. This
frees up enough space to allow the core tests to run.
Set the initial stack pointer to the end of ram so it matches
INITIAL_SP defined in RTX_CM_lib.h.
The config store tests use more than 2K of the interrupt stack, causing
an overflow.  This patch bumps the K64F interrupt stack size to 4K
for ARMCC and GCC. The IAR interrupt stack is left untouched since
it is 32K.
@c1728p9 c1728p9 force-pushed the main_thread_stack_checking branch from 66bc6a2 to 1d2d9bd Compare August 9, 2016 19:40
@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 9, 2016

/morph test

@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 9, 2016

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=GCC_ARM,ARM,IAR
TARGETS=K64F,NRF51_DK,NRF51_MICROBIT,NUCLEO_F411RE

@mbed-bot
Copy link

mbed-bot commented Aug 9, 2016

[Build 789]
SUCCESS: Building succeeded and tests were run! Be sure to check the test results

@mbed-bot
Copy link

mbed-bot commented Aug 9, 2016

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 622

Test Cleanup failed!

@bridadan
Copy link
Contributor

bridadan commented Aug 9, 2016

Interesting error (Test Cleanup), looking into it now. But tests all passed 👍

@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 9, 2016

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=GCC_ARM,ARM,IAR
TARGETS=K64F,NRF51_DK,NRF51_MICROBIT,NUCLEO_F411RE

@mbed-bot
Copy link

mbed-bot commented Aug 9, 2016

[Build 791]
SUCCESS: Building succeeded and tests were run! Be sure to check the test results

@c1728p9 c1728p9 closed this Aug 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants