zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.88k stars 6.63k forks source link

nsim_em: kernel.common.stack_protection Fail #68682

Open KamilxPaszkiet opened 9 months ago

KamilxPaszkiet commented 9 months ago

Describe the bug tests/kernel/fatal/exception/kernel.common.stack_protection fail.

To Reproduce twister -p nsim_em -s tests/kernel/fatal/exception/kernel.common.stack_protection

Logs and console output

*** Booting Zephyr OS build v3.6.0-rc1-194-g1cadd91b05a1 ***
Running TESTSUITE fatal_exception
===================================================================
START - test_fatal
test alt thread 1: generic CPU exception
E: ***** Exception vector: 0x8, cause code: 0x0, parameter 0x0
E: Address 0xc0
E: EV_SWI
E:  r0: 0x0  r1: 0x0  r2: 0x0  r3: 0x0
E:  r4: 0x0  r5: 0x0  r6: 0x0  r7: 0xfffffff5
E:  r8: 0x0  r9: 0x0 r10: 0x0 r11: 0x0
E: r12: 0xb8 r13: 0x0  pc: 0xc0
E:  blink: 0xef0 status32: 0x80186006
E: lp_end: 0x0 lp_start: 0x0 lp_count: 0x0
E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Current thread: 0x80001824 (unknown)
Caught system error -- reason 0
test alt thread 1: generic CPU exception divide zero
E: ***** Exception vector: 0x8, cause code: 0x0, parameter 0x0
E: Address 0x248
E: EV_SWI
E:  r0: 0x0  r1: 0x0  r2: 0x0  r3: 0x0
E:  r4: 0x0  r5: 0x0  r6: 0x0  r7: 0xfffffff5
E:  r8: 0x0  r9: 0x80001b4c r10: 0x8 r11: 0x2326
E: r12: 0x240 r13: 0x0  pc: 0x248
E:  blink: 0xef0 status32: 0x80186006
E: lp_end: 0x0 lp_start: 0x80001824 lp_count: 0x800018cc
E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Current thread: 0x80001824 (unknown)
Caught system error -- reason 0
test alt thread 2: initiate kernel oops
E:  r0: 0x3  r1: 0x0  r2: 0x0  r3: 0x0
E:  r4: 0x0  r5: 0x0  r6: 0x0  r7: 0xfffffff5
E:  r8: 0x0  r9: 0x80001b4c r10: 0x8 r11: 0x2326
E: r12: 0xd4 r13: 0x0  pc: 0xe2
E:  blink: 0xef0 status32: 0x80186006
E: lp_end: 0x0 lp_start: 0x80001824 lp_count: 0x800018cc
E: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
E: Current thread: 0x80001824 (unknown)
Caught system error -- reason 3
test alt thread 3: initiate kernel panic
E:  r0: 0x4  r1: 0x0  r2: 0x0  r3: 0x0
E:  r4: 0x0  r5: 0x0  r6: 0x0  r7: 0xfffffff5
E:  r8: 0x0  r9: 0x80001b4c r10: 0x8 r11: 0x2326
E: r12: 0xe4 r13: 0x0  pc: 0xf2
E:  blink: 0xef0 status32: 0x80186006
E: lp_end: 0x0 lp_start: 0x80001824 lp_count: 0x800018cc
E: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
E: Current thread: 0x80001824 (unknown)
Caught system error -- reason 4
test alt thread 4: fail assertion
ASSERTION FAIL [0] @ WEST_TOPDIR/tests/kernel/fatal/exception/src/main.c:159
    intentionally failed assertion
E:  r0: 0x4  r1: 0x9f  r2: 0x80001824  r3: 0x0
E:  r4: 0x0  r5: 0x0  r6: 0x0  r7: 0xfffffff5
E:  r8: 0x0  r9: 0x80001b4c r10: 0x8 r11: 0x2326
E: r12: 0xffffffff r13: 0xb818  pc: 0xf54
E:  blink: 0x14c status32: 0x80186006
E: lp_end: 0x0 lp_start: 0x80001824 lp_count: 0x800018cc
E: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
E: Current thread: 0x80001824 (unknown)
Caught system error -- reason 4
test alt thread 5: initiate arbitrary SW exception
E:  r0: 0x7fffffff  r1: 0x0  r2: 0x7fffffff  r3: 0x0
E:  r4: 0x0  r5: 0x0  r6: 0x0  r7: 0xfffffff5
E:  r8: 0x0  r9: 0x80001b4c r10: 0x8 r11: 0x2326
E: r12: 0xf4 r13: 0x0  pc: 0x10a
E:  blink: 0xef0 status32: 0x80186006
E: lp_end: 0x0 lp_start: 0x80001824 lp_count: 0x800018cc
E: >>> ZEPHYR FATAL ERROR 2147483647: Unknown error on CPU 0
E: Current thread: 0x80001824 (unknown)
Caught system error -- reason 2147483647
test alt thread 6: initiate arbitrary SW exception negative
E:  r0: 0xfffffffe  r1: 0x0  r2: 0x0  r3: 0x0
E:  r4: 0x0  r5: 0x0  r6: 0x0  r7: 0xfffffff5
E:  r8: 0x0  r9: 0x80001b4c r10: 0x8 r11: 0x2326
E: r12: 0x10c r13: 0x0  pc: 0x11a
E:  blink: 0xef0 status32: 0x80186006
E: lp_end: 0x0 lp_start: 0x80001824 lp_count: 0x800018cc
E: >>> ZEPHYR FATAL ERROR -2: Unknown error on CPU 0
E: Current thread: 0x80001824 (unknown)
Caught system error -- reason -2
test stack HW-based overflow - supervisor 1
E: ***** Exception vector: 0x6, cause code: 0x2, parameter 0x2
E: Address 0x80002ff0
E: EV_ProtV
E: Memory write protection violation (stack checking scheme)
E:  r0: 0x0  r1: 0x0  r2: 0x0  r3: 0x0
E:  r4: 0x0  r5: 0x0  r6: 0x0  r7: 0x5
E:  r8: 0x0  r9: 0x80001b4c r10: 0x8 r11: 0x2326
E: r12: 0x2f4 r13: 0x0  pc: 0x7c
E:  blink: 0x90 status32: 0x80186006
E: lp_end: 0x0 lp_start: 0x80001824 lp_count: 0x800018cc
E: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
E: Current thread: 0x80001824 (unknown)
Caught system error -- reason 2
test stack HW-based overflow - supervisor 2
E: ***** Exception vector: 0x6, cause code: 0x2, parameter 0x2
E: Address 0x80002ff0
E: EV_ProtV
E: Memory write protection violation (stack checking scheme)
E:  r0: 0x0  r1: 0x0  r2: 0x0  r3: 0x0
E:  r4: 0x0  r5: 0x0  r6: 0x0  r7: 0x5
E:  r8: 0x0  r9: 0x80001b4c r10: 0x8 r11: 0x2326
E: r12: 0x2f4 r13: 0x0  pc: 0x7c
E:  blink: 0x90 status32: 0x80186006
E: lp_end: 0x0 lp_start: 0x80001824 lp_count: 0x800018cc
E: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
E: Current thread: 0x80001824 (unknown)
Caught system error -- reason 2
test stack HW-based overflow - user 1
E: ***** Exception vector: 0x6, cause code: 0x2, parameter 0x4
E: Address 0x80002ffc
E: EV_ProtV
E: Memory write protection violation (MPU)
E:  r0: 0x0  r1: 0x0  r2: 0x0  r3: 0x0
E:  r4: 0x0  r5: 0x0  r6: 0x0  r7: 0x0
E:  r8: 0x0  r9: 0x0 r10: 0x0 r11: 0x0
E: r12: 0x2f4 r13: 0x0  pc: 0x80
E:  blink: 0x90 status32: 0x80186086
E: lp_end: 0x0 lp_start: 0x80001824 lp_count: 0x800018cc
E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Current thread: 0x80001824 (unknown)
Caught system error -- reason 0
Wrong crash type got 0 expected 2
PROJECT EXECUTION FAILED

Environment:

nashif commented 9 months ago

@evgeniy-paltsev @abrodkin @kokas-a

kokas-a commented 9 months ago

Became broken after b898541809b85292dd5b6928ab34cad0be23da57 commit

ruuddw commented 9 months ago

That might be a coincidence. Looks like both the MPU check and stack bounds check are/should be triggered at the same time, but only the MPU one is reported by nSIM. Could be a simulator cornercase.

github-actions[bot] commented 7 months ago

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

github-actions[bot] commented 5 months ago

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

github-actions[bot] commented 3 months ago

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

evgeniy-paltsev commented 2 months ago

The issue is caused by peculiarities of ARC GNU toolchain code generation, see more details here: https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/issues/643

The ARC MWDT toolchain is not affected.

github-actions[bot] commented 4 weeks ago

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.