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

Enabling TLS detects stack overflow in a few tests #53687

Merged
merged 4 commits into from
Jan 26, 2023

Conversation

keith-packard
Copy link
Collaborator

Because TLS stores critical thread information at the top of each stack, overflows in subsequent stacks will write over that and cause general chaos. This means that enabling thread local storage will cause some tests to fail simply because they overflow their stacks in a way which was not detected without TLS enabled.

These three patches increase stack sizes in tests (probably by way more than necessary) to make them work when thread local storage is enabled.

@keith-packard
Copy link
Collaborator Author

ok, as #53590 shows, this series now gets all tests passing with TLS enabled, so this series should actually be ready to merge.

dcpleung
dcpleung previously approved these changes Jan 11, 2023
Picolibc is enough faster than the minimal C library that the zbus
benchmark will likely complete in well under 10ms on qemu_nios2. As this
target cannot provide a clock at higher resolution than the system tick, we
need to increase that rate to get a non-zero runtime for this benchmark.

Add new nios2-specific config variables that change the
CONFIG_SYS_CLOCK_TICKS_PER_SEC value, leaving all other platforms using the
standard value. We cannot just increase it for every platform as
qemu_arc_hs6x fails with a 1kHz rate.

Signed-off-by: Keith Packard <[email protected]>
Enabling TLS increases stack usage by a small amount as that is where any
TLS variables are stored. When enabled, this sample ends up overflowing the
512-byte subscriber task stack and the IDLE_STACK_SIZE consumer stacks

Replace the fixed 512-byte subscriber stack allocation with
CONFIG_MAIN_STACK_SIZE so that it adopts a value controlled by the
configuration in case it needs to be adjusted further.

Increased CONFIG_IDLE_STACK_SIZE to 1024 to provide more space in each
consumer stack.

Signed-off-by: Keith Packard <[email protected]>
This test overflows when TLS is used, provide plenty of extra space to
avoid that.

Signed-off-by: Keith Packard <[email protected]>
When thread local storage is enabled, log_core_additional generates stack
overflows in the main thread on several architectures. Increase the stack
size to 4096 bytes for this thread.

Signed-off-by: Keith Packard <[email protected]>
@fabiobaltieri fabiobaltieri merged commit 65427f4 into zephyrproject-rtos:main Jan 26, 2023
@keith-packard keith-packard deleted the test-stack-size branch January 26, 2023 19:43
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.

6 participants