-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Labels
bugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bugMedium impact/importance bug
Milestone
Description
hello
I found a fault during my timer testing.
zephyr version: 1.9.1
code:
_struct k_timer test_timer, test_timer2;
static void test_timeout_event(os_timer *timer)
{
}
static void test2_timeout_event(os_timer *timer)
{
k_timer_start(&test_timer, K_MSEC(10), K_MSEC(20));
}
void test_timer(void)
{
k_timer_init(&test_timer, test_timeout_event, NULL);
k_timer_init(&test_timer2, test2_timeout_event, NULL);
k_timer_start(&test_timer, K_MSEC(10), K_MSEC(20));
while(1) {
k_timer_start(&test_timer2, K_MSEC(100), 0);
k_sleep(K_MSEC(1000));
}
}
analysis:
when timer1 & timer2 expired in the same tick, timer1 & timer2 will be dequeue from _timeout_q to expired.
In timer2 callback function, k_timer_start(&test_timer, K_MSEC(10), K_MSEC(20)) will re-insert timer1 to _timeout_q. After timer2 callback function, the expired sys_dlist(in _handle_expired_timeouts()) has changed.
The callback of timer linked in the _timeout_q will be called in order. when run last timeout(_timeout_q which actually is not a timer structure),run timeout->func will trigger a fault.
Metadata
Metadata
Assignees
Labels
bugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bugMedium impact/importance bug