You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
On POSIX, we noticed that stack usage seems higher than expected.
This is a concern because this is not being adequately budgeted for in typical CFE startup scripts, which only focus on the stack needed by the app itself, not the overhead imposed by the OS/library.
To Reproduce
This can be confirmed by checking the stackusage on the OSAL functional test (e.g. osal-core-test).
Partial output from running stackusage ./osal-core-test:
Basically - what this is saying is that the baseline stack use of a "nothing" thread is still using 9.3 kB of stack space.
System observed on:
Debian
Additional context
This is certainly due to the way the glibc pthreads implementation deals with the TCB and TLS structures. In the non-main threads on on x86-64 platform, it just puts these structures at the top of the stack.
This correlates with what we are observing here, in that the TCB+TLS structures consume almost 10kB of stack space before even getting to the entry point of the task.
The real problem occurs if the user has fine-tuned/measured their stack usage on an RTOS like VxWorks. Most CFS apps only really need a few kB of stack space to run, so if a cfe_es_startup.scr file calls for a stack of 8192 bytes (because that's what the app needs) then the stack will end up being too small on POSIX because of this extra usage that hadn't been accounted for.
Reporter Info
Joseph Hickey, Vantage Systems, Inc.
The text was updated successfully, but these errors were encountered:
Describe the bug
On POSIX, we noticed that stack usage seems higher than expected.
This is a concern because this is not being adequately budgeted for in typical CFE startup scripts, which only focus on the stack needed by the app itself, not the overhead imposed by the OS/library.
To Reproduce
This can be confirmed by checking the stackusage on the OSAL functional test (e.g.
osal-core-test
).Partial output from running
stackusage ./osal-core-test
:The 6th column - 9320 - refers to the maximum amount of stack used by one of the child threads spawned in this test.
The concern here is that these threads do nothing:
osal/src/tests/osal-core-test/osal-core-test.c
Lines 110 to 116 in 0291622
Basically - what this is saying is that the baseline stack use of a "nothing" thread is still using 9.3 kB of stack space.
System observed on:
Debian
Additional context
This is certainly due to the way the glibc pthreads implementation deals with the TCB and TLS structures. In the non-main threads on on x86-64 platform, it just puts these structures at the top of the stack.
An excellent description of the topic is here: https://chao-tic.github.io/blog/2018/12/25/tls
This correlates with what we are observing here, in that the TCB+TLS structures consume almost 10kB of stack space before even getting to the entry point of the task.
The real problem occurs if the user has fine-tuned/measured their stack usage on an RTOS like VxWorks. Most CFS apps only really need a few kB of stack space to run, so if a
cfe_es_startup.scr
file calls for a stack of 8192 bytes (because that's what the app needs) then the stack will end up being too small on POSIX because of this extra usage that hadn't been accounted for.Reporter Info
Joseph Hickey, Vantage Systems, Inc.
The text was updated successfully, but these errors were encountered: