-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[FIX] add NULL pointer check to xTaskIncrementTick() #1249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/bot run formatting |
|
@InnerSteff I'm trying to figure out the use cases where the SysTick Timer would be configured and started by the application before the scheduler is started (which would re-configure and take over the SysTick Timer), are you facing any issues with the current implementation? |
Yes I had an issue with it. In my special case I can not use the SysTick Timer. And it happened that xTaskIncrementTick() was called before the first task was created. This lead to the NULL point access. And a crash of my application. It took me quite long to find the reason for the crash. The assert would have helped me a lot, and I thought it might also help others. |
Instead of an assert, should this not ignore the systick if the scheduler is not yet started? |
If the SysTick Timer is not configured and enabled by the application, then the SysTick Timer Interrupt handler |
I am not using the My application is working fine now. But it was difficult to find the NULL pointer access which caused my application to crash. Thats why I am suggesting this improvement. |
The correct way to use a different timer other than SysTick is to override the weak function vPortSetupTimerInterrupt. Implement |
No this would not fix my issue, because I must setup my Interrupt handler before I start the scheduler. Therefore setting up my interrupt within |
Do you mean to say that you must start your hardware timer that drives the FreeRTOS tick, before the scheduler is started? If yes, would you please share the reason? Also, which hardware are you using? |
Yes, you are right. My system tick must be synchronized with the periodic communication of an external second processor. Therefore, my system tick interrupt is actually not a timer, but the receive interrupt of the communication interface. The communication interface must be set up before the scheduler is started, because some communication must be done before creating the tasks and starting the scheduler. Using the system tick time or any other processor internal timer led to drifting apart of the system tick and the communication. Therefore, I decided to use the communication interrupt also for the system tick |
Thank you for explaining. This does seem a special case where some Rx interrupt drives the tick instead of a periodic timer. In that case, your implementation of checking the scheduler state is the correct one. I recommend against adding this additional assert in xTaskIncrementTick. Since this function is called at a high frequency, introducing an assert for this special case would be an unnecessary performance penalization in normal operations. The potential cost outweighs the benefit. |
add NULL pointer check of pxDelayedTaskList to xTaskIncrementTick()
Description
if the system tick interrupt is started independent from the
scheduler the first tick increment might occur before the
the first task is created and therefore pxDelayedTaskList is
still not set
Test Steps
Set up the system tick hander before the scheduler is started
Checklist:
Related Issue
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.