Skip to content

Fix for Thread::max_stack not returning right value when OS_STACK_WATERMARK is enabled #7545

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
Jul 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rtos/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ osStatus Thread::start(Callback<void()> task) {

//Fill the stack with a magic word for maximum usage checking
for (uint32_t i = 0; i < (_attr.stack_size / sizeof(uint32_t)); i++) {
((uint32_t *)_attr.stack_mem)[i] = 0xE25A2EA5;
((uint32_t *)_attr.stack_mem)[i] = osRtxStackMagicWord;
}

memset(&_obj_mem, 0, sizeof(_obj_mem));
Expand Down Expand Up @@ -306,7 +306,7 @@ uint32_t Thread::max_stack() {
#if defined(MBED_OS_BACKEND_RTX5)
mbed_rtos_storage_thread_t *thread = (mbed_rtos_storage_thread_t *)_tid;
uint32_t high_mark = 0;
while (((uint32_t *)(thread->stack_mem))[high_mark] == 0xE25A2EA5)
while ((((uint32_t *)(thread->stack_mem))[high_mark] == osRtxStackMagicWord) || (((uint32_t *)(thread->stack_mem))[high_mark] == osRtxStackFillPattern))
high_mark++;
size = thread->stack_size - (high_mark * sizeof(uint32_t));
#else
Expand Down