chuan-jiang wrote on Monday, November 20, 2017:
Hi,
I’ve noticed a possible overflow issue in xTaskCheckForTimeOut function. Could you please help to confirm it?
In the latest RTOSv9.0.1, task.c, line3154,
const TickType_t xElapsedTime = xConstTickCount - pxTimeOut->xTimeOnEntering;
Noticed that TickType_t might be defined as unsigned type, if xConstTickCount is less than pxTimeOut->xTimeOnEntering, the substraction will lead to an overflow.
and then in line3187,
*else if( xElapsedTime < pxTicksToWait )
I think this check condition should also take xNumOfOverflows into account.
(1) if xNumOfOverflows equals pxTimeOut->xOverflowCount+1, timeout might not be reached.
(2) but if xNumOfOverflows is larger than pxTimeOut->xOverflowCount+1, it might be the wrapped around, and the timeout has been passed away when this function is invoked. Then the return value should not be FALSE!
Also, xNumOfOverflows might also be wrapped around when come to xTaskCheckForTimeOut again.
Looking forwarding to your help and reply.
Thanks a lot