Skip to content

Commit 28481ed

Browse files
author
Andy Ross
committed
tests/kernel/fatal: Fix clobbered k_timer
The tests all share a stack, so by putting the k_timer on the stack we're potentially allowing it to be clobbered by a following test before it expires. Make it static. Oddly this "worked" when written, becuase it initialized the timer after the stack clobber, even though the rest of the stack was already garbage, and because the timing just happened to expire before the next test got to it. Mucking around with timeout expirations exposed the bug. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
1 parent a7b7db8 commit 28481ed

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/kernel/fatal/src/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,11 @@ void stack_sentinel_timer(void)
137137
{
138138
/* We need to guarantee that we receive an interrupt, so set a
139139
* k_timer and spin until we die. Spinning alone won't work
140-
* on a tickless kernel.
140+
* on a tickless kernel. Note static: we can't place it on
141+
* our stack, because it can be clobbered by the next test
142+
* before it expires!
141143
*/
142-
struct k_timer timer;
144+
static struct k_timer timer;
143145

144146
blow_up_stack();
145147
k_timer_init(&timer, NULL, NULL);

0 commit comments

Comments
 (0)