vTaskDelay(0) on last tick before clock wraparound ASSERTS in tasks.c

oyhovd wrote on Friday, March 15, 2019:


There seems to be an issue with vTaskDelay() and clock wraparound. If I call vTaskDelay with 0 ticks as parameter close to clock wraparound, I will get an assert in tasks.c line 2612 (v10.0.0, there is no option for me to upgrade to a later version at this point to check, but by code inspection it looks the same), in xTaskIncrementTick(). This assert looks like it is due to the line

configASSERT( ( listLIST_IS_EMPTY( pxDelayedTaskList ) ) );


On inspection of the code, it looks like prvAddCurrentTaskToDelayedList() adds the delayed task to pxDelayedTaskList when the xTicksToDelay is 0. If this is in the last tick before wraparound, it would seem that the task is still in that list when xTaskIncrementTick() runs on wraparound.

vTaskDelayUntil would probably be affected by the same thing.

The workaround for me now is to not use vTaskDelayUntil(), and never pass 0 to vTaskDelay().

rtel wrote on Friday, March 15, 2019:

Duplicate of https://sourceforge.net/p/freertos/discussion/382005/thread/8e0db48a54/