-
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
Mark mutex as robust to prevent deadlocks #1233
Conversation
Prevent application hangs that occur when a thread dies while holding a mutex, particularly during vTaskEndScheduler or exit calls. This is achieved by setting the PTHREAD_MUTEX_ROBUST attribute on the mutex. Fixes: - GitHub issue: FreeRTOS#1217 - Forum thread: freertos.org/t/22287 Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1233 +/- ##
==========================================
- Coverage 91.64% 91.53% -0.11%
==========================================
Files 6 6
Lines 3254 3260 +6
Branches 903 901 -2
==========================================
+ Hits 2982 2984 +2
- Misses 132 135 +3
- Partials 140 141 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Tested on my end. |
Quality Gate passedIssues Measures |
@@ -46,23 +48,36 @@ struct event * event_create( void ) | |||
if( ev != NULL ) | |||
{ | |||
ev->event_triggered = false; | |||
pthread_mutex_init( &ev->mutex, NULL ); | |||
pthread_mutexattr_init( &ev->mutexattr ); | |||
#ifndef __APPLE__ |
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 wonder how we can get similar benefits on macOS/iOS
Description
Prevent application hangs that occur when a thread dies while holding a mutex, particularly during vTaskEndScheduler or exit calls. This is achieved by setting the PTHREAD_MUTEX_ROBUST attribute on the mutex.
Test Steps
Tested locally using the modified application as suggested in this thread. Was also tested by @denravonska.
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.