-
Notifications
You must be signed in to change notification settings - Fork 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
core/thread: error in thread.c corrected #21253
base: master
Are you sure you want to change the base?
Conversation
- in thread_wakeup() the status of the function to be woken up is incorrectly set to TASK_RUNNING. Instead the task should be set to STATUS_PENDING here, as only sched_run() is allowed to set a task to TASK_RUNNING. - in thread_create() it is checked whether the stack is large enough, but instead of aborting the function if the stack is too small and thus preventing a buffer overflow, only a debug output is made. Return statement added - in thread_state_to_string() it is not checked whether state is within the valid range, so that in the event of an error an invalid memory address is returned, which in turn leads to further invalid memory accesses when the string is output. thread_state_to_string() is used in particular by ps(). In the case of a corrupt thread context, which often occurred in my case due to the stack size being too small, thread_state_to_string() is called with an invalid status. Other - thread_add_to_list(): Adding the task to the linked list is graphically commented (If you are interested, I also prepared this for core\lib\include\list.h and core\lib\include\clist.h)
Remove Trailing Whitespace
Co-authored-by: Karl Fessel <[email protected]>
assert(state < STATUS_NUMOF); | ||
const char *name = state_names[state]; |
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.
i think this is more reliable -- check for not exceeding NUMOF even if assertion are disabled
assert(state < STATUS_NUMOF); | |
const char *name = state_names[state]; | |
const char *name = NULL; | |
if (state < STATUS_NUMOF){ | |
name = state_names[state]; | |
} | |
/* if compiling with assertions, this is an error that indicates that the table above is incomplete */ | |
assert(name != NULL) | |
return (name != NULL) ? name : STATE_NAME_UNKNOWN; |
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.
i could not add a suggestion to the unchanged code assert(name != NULL);
-> i attached it to the first two lines
Contribution description
Errors in thread.c corrected:
Other
Testing procedure
Issues/PRs references