-
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
Add an assert o catch overflow of recursive mutex counter #1254
Conversation
Does this change attempt to catch infinite recursion of |
This change attempt to catch an infinite call of xSemaphoreTakeRecursive(). It’s a theoretical bug fix I came across during design phase of my application when someone asked how often you can take a recursive mutex. But, according to my understanding, it can not only occur in an infinite recursion scenario, but also if xSemaphoreTakeRecursive() is called in an infinite loop. Or in a loop with more iteration than the max value of UBaseType_t. |
Agree, but that would be a poorly written application. No sane application would do that. Asserts are there to help programmers to catch reasonable mistakes. |
Signed-off-by: Gaurav Aggarwal <[email protected]>
Signed-off-by: Gaurav Aggarwal <[email protected]>
|
Thanks for picking up and merging my pull request, but may I ask what changed your mind to accept it? |
In our internal discussion, we realized that this check may help to catch a situation where somebody keeps taking a mutex but never gives it back. Thank you for your contribution! |
Fix add overflow check on recursive mutex counter
Description
There is no overflow check of the recursive mutex counter yet.
If the counter overflows, the mutex will be released on the next call of xQueueGiveMutexRecursive(),
even if the number of calls does not match the number of calls of xQueueTakeMutexRecursive().
This would lead to unpredictable behavior in the application.
Test Steps
call xQueueTakeMutexRecursive() more than the maximum value of UBaseType_t
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.