-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fixed buffer underflow in prvSelectHighestPriorityTask
.
#607
Fixed buffer underflow in prvSelectHighestPriorityTask
.
#607
Conversation
Thanks for submitting this, we'll take a look |
Our CI is a little bit of a pain right now. I'm going to push a commit to your change to update this line. This should stop the header check from failing. Essentially Python 3.7.10 isn't available on Ubuntu 20.04 anymore. This won't have any impact on the functionality of your PR and is purely to fix the CI. |
Python 3.7.10 is no longer supported. Python 3.11.0 is preferred.
if(uxTopReadyPriority > 0) { | ||
uxTopReadyPriority--; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick, non-blocking: I realize 0
isn't exactly a magic number in this context BUT I would prefer this line to say uxTopReadyPriority > tskIDLE_PRIORITY
. This would read like "The Top Ready Priority cannot be less than the idle task" rather than "The Top Ready Priority cannot be less than 0". While these are functionally the same, pinning this to the idle task would make it clearer that no task can be lower in priority than the idle task.
if(uxTopReadyPriority > 0) { | ||
uxTopReadyPriority--; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formatting should be something like the following (to adhere to the Kernel's formatting style)
if(uxTopReadyPriority > 0) { | |
uxTopReadyPriority--; | |
} | |
/* The top ready priority cannot be less than the idle task's priority. */ | |
if( uxTopReadyPriority > tskIDLE_PRIORITY ) | |
{ | |
uxTopReadyPriority--; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @tobireinhard,
Just a couple of comments regarding formatting (also included the suggestion by @kstribrnAmzn). If they seem correct to you, would you mind pushing them?
Thanks,
Aniruddha
if(uxCurrentPriority > 0) { | ||
uxCurrentPriority--; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly here as well
if(uxCurrentPriority > 0) { | |
uxCurrentPriority--; | |
} | |
/* The top ready priority cannot be less than the idle task's priority. */ | |
if( uxCurrentPriority > tskIDLE_PRIORITY ) | |
{ | |
uxCurrentPriority--; | |
} |
I would like to share some observation about this problem. Suggest we consider to update the vTaskSuspend function and ensure that prvSelectHighestPriorityTask won't be called before scheduler started in another PR. |
Closing this PR as it is no longer needed after #610. |
Add a hardware definition project for the MicroZed board to the existing Zynq ZC702 project. Add a text file that describes how to switch the Zynq project form the ZC702 hardware to the MicroZed hardware.
Fixed buffer underflow in
prvSelectHighestPriorityTask
.Description
The function
prvSelectHighestPriorityTask
is called fromvTaskSwitchContext
whenever the scheduler selects a new task to run. It can also be called fromvTaskSuspend
before the scheduler is running and before the idle tasks have been created.In the latter case, the global variable
uxTopReadyPriority
is decreased to -1. During the next regular context switch,prvSelectHighestPriorityTask
tries to access the global ready list arraypxReadyTasksLists[ uxCurrentPriority ]
. This causes a memory error.Test Steps
Initialize the ready lists stored in
pxReadyTasksLists
to be empty and callprvSelectHighestPriorityTask
. Check that after the the function terminates, the global variableuxTopReadyPriority
has value -1. CallvTaskSwitchContext
and check that it causes a buffer underflow.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.