Skip to content
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

feature request: option to exclude thread-local storage from coredumps #85

Closed
JordanYates opened this issue Jan 13, 2025 · 2 comments
Closed
Assignees

Comments

@JordanYates
Copy link

The thread stack coredump logic currently takes into account the case where less data exists than CONFIG_MEMFAULT_COREDUMP_STACK_SIZE_TO_COLLECT.

// We know where the top of the stack is. Use that information to shrink
// the area we need to collect if less than CONFIG_MEMFAULT_COREDUMP_STACK_SIZE_TO_COLLECT
// is in use
const uint32_t stack_top = thread->stack_info.start + thread->stack_info.size;
size_t stack_size_to_collect =
MEMFAULT_MIN(stack_top - (uint32_t)sp, CONFIG_MEMFAULT_COREDUMP_STACK_SIZE_TO_COLLECT);

However it does not take into account that a application specific amount at the top of the stack can be reserved for thread-local storage. This can be a non-trivial amount of ram (56 bytes on my nRF9151 application, ~20% of the default CONFIG_MEMFAULT_COREDUMP_STACK_SIZE_TO_COLLECT).
The size of this TLS data is accessible in the stack_info.delta variable.
https://github.com/zephyrproject-rtos/zephyr/blob/99a63a776980f855493ceb99036a5974a2b68fb5/include/zephyr/kernel/thread.h#L169-L173

In RAM limited applications, it would be good to have the option to exclude TLS data from the coredumps, so that the space can be allocated to more useful information.

@noahp noahp self-assigned this Jan 16, 2025
@noahp
Copy link
Contributor

noahp commented Jan 27, 2025

Thanks for reporting, @JordanYates , apologies for my slow response here- I'll add an option to our next SDK release to support this!

@noahp
Copy link
Contributor

noahp commented Feb 10, 2025

This is fixed in 1.20.0. Let me know if there's any issues!

@noahp noahp closed this as completed Feb 10, 2025
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

No branches or pull requests

2 participants