This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

app_timer2 timer list corruption seen on rtc overflow

I'm trying to track down an issue where our application gets stuck due to what looks like an infinite loop in the app_timer2 timer list.  When it occurs we see the next pointer of the head element pointing back to the the head.

To detect this condition I've added guards to all the methods in nrf_sortlist.

ASSERT(p_list->p_cb->p_head != p_list->p_cb->p_head->p_next);

I'm seeing this occur repeatedly with the call stack shown above.  on_overflow() calls timer_expire() on a late timer.  Since the timer has a repeat period timer_expire() reschedules the timer but on_overflow() only peeked at the timer, it never removed it from the list.  This timer is still at the head so it gets added to the list in front of itself and the loop is formed.

I'm trying hacks to fix this, I'm fairly sure that on_overflow should be popping the timer from the queue before calling timer_expire()  In the non-overflow case rtc_update() pops the timer from the list before calling rtc_schedule(), which then calls timer_expire().

I'm using an nrf52832 with SDK 15.2 and softdevice 6.1

Related