-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
mps2_an385 crashes if CONFIG_INIT_STACKS=y and CONFIG_COVERAGE=y #15794
Comments
from log, it's the instruction located in 0x8656(in memset) caused the BUS fault. And it tries to access 0xaaaaaaaa, so there is bus fault. Haven't got the root cause, still checking it. |
added some debug code and also from above log
and from set_and_switch_to_psp code below, when return from set_and_switch_to_psp, there will be "mov sp, r7" , so it will still write the original stack(see vector table) address to sp (even it's PSP now) instead of _interrupt_stack as code designed.
|
with above temp changes, only the last sub test of tests/kernel/mem_protect/userspace fails as below, so I think the original crash problem has been fixed. I'm preparing PR. I will open another github issue track below problem. Thanks. starting test - test_stack_buffer
|
Right. It was really a bad idea to move this code to C from assembly. |
With -O0 optimizion, gcc compiler doesn't inline "static inline" marked function. So when function call return from function set_and_switch_to_psp which is to switch sp from MSP to PSP, the ending "mov sp, r7" instruction will overwrite the just updated sp value(PSP) with the beginning stack pointer(should be MSP) stored in r7 register, so the switch doesn't happen. And it causes unpredictable problems in the initialization process, the backward analysis for this problem can be found on Github issue zephyrproject-rtos#15794. Fixes: zephyrproject-rtos#15794. Signed-off-by: Wentong Wu <[email protected]>
increase stack buffer when code coverage enabled. Fixes: zephyrproject-rtos#15794. Signed-off-by: Wentong Wu <[email protected]>
With -O0 optimizion, gcc compiler doesn't inline "static inline" marked function. So when function call return from function set_and_switch_to_psp which is to switch sp from MSP to PSP, the ending "mov sp, r7" instruction will overwrite the just updated sp value(PSP) with the beginning stack pointer(should be MSP) stored in r7 register, so the switch doesn't happen. And it causes unpredictable problems in the initialization process, the backward analysis for this problem can be found on Github issue #15794. Fixes: #15794. Signed-off-by: Wentong Wu <[email protected]>
increase stack buffer when code coverage enabled. Fixes: #15794. Signed-off-by: Wentong Wu <[email protected]>
With -O0 optimizion, gcc compiler doesn't inline "static inline" marked function. So when function call return from function set_and_switch_to_psp which is to switch sp from MSP to PSP, the ending "mov sp, r7" instruction will overwrite the just updated sp value(PSP) with the beginning stack pointer(should be MSP) stored in r7 register, so the switch doesn't happen. And it causes unpredictable problems in the initialization process, the backward analysis for this problem can be found on Github issue #15794. Fixes: #15794. Signed-off-by: Wentong Wu <[email protected]>
increase stack buffer when code coverage enabled. Fixes: #15794. Signed-off-by: Wentong Wu <[email protected]>
With -O0 optimizion, gcc compiler doesn't inline "static inline" marked function. So when function call return from function set_and_switch_to_psp which is to switch sp from MSP to PSP, the ending "mov sp, r7" instruction will overwrite the just updated sp value(PSP) with the beginning stack pointer(should be MSP) stored in r7 register, so the switch doesn't happen. And it causes unpredictable problems in the initialization process, the backward analysis for this problem can be found on Github issue zephyrproject-rtos#15794. Fixes: zephyrproject-rtos#15794. Signed-off-by: Wentong Wu <[email protected]>
increase stack buffer when code coverage enabled. Fixes: zephyrproject-rtos#15794. Signed-off-by: Wentong Wu <[email protected]>
With -O0 optimizion, gcc compiler doesn't inline "static inline" marked function. So when function call return from function set_and_switch_to_psp which is to switch sp from MSP to PSP, the ending "mov sp, r7" instruction will overwrite the just updated sp value(PSP) with the beginning stack pointer(should be MSP) stored in r7 register, so the switch doesn't happen. And it causes unpredictable problems in the initialization process, the backward analysis for this problem can be found on Github issue #15794. Fixes: #15794. Signed-off-by: Wentong Wu <[email protected]>
increase stack buffer when code coverage enabled. Fixes: #15794. Signed-off-by: Wentong Wu <[email protected]>
If both of these configs get enabled, we get a bus fault:
Note that the thread ID information is bogus since we are in early boot context.
The crash happens in the call to memset() in z_new_thread_init() when it tries to write 0xAA to the stack buffer (which is what CONFIG_INIT_STACKS does) for the main thread.
To reproduce, add the lines:
to samples/hello_world/prj.conf and run on mps2_an385.
First noticed with tests/kernel/mem_protect/userspace, but not specific to that test
The text was updated successfully, but these errors were encountered: