Skip to content

Conversation

@aggarg
Copy link
Member

@aggarg aggarg commented Jan 25, 2025

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:

  • I have tested my changes. No regression in existing tests.
  • [NA] I have modified and/or added unit-tests to cover the code changes in this Pull Request.

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.

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 <[email protected]>
@codecov
Copy link

codecov bot commented Jan 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.53%. Comparing base (31dd1e3) to head (92be5d4).
Report is 17 commits behind head on main.

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     
Flag Coverage Δ
unittests 91.53% <ø> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@denravonska
Copy link

Tested on my end. vTaskEndScheduler no longer deadlocks for me.

@sonarqubecloud
Copy link

@aggarg aggarg merged commit ad4e723 into FreeRTOS:main Jan 29, 2025
17 checks passed
@aggarg aggarg deleted the posix_port branch January 29, 2025 01:57
ev->event_triggered = false;
pthread_mutex_init( &ev->mutex, NULL );
pthread_mutexattr_init( &ev->mutexattr );
#ifndef __APPLE__
Copy link
Contributor

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

moninom1 pushed a commit to moninom1/FreeRTOS-Kernel that referenced this pull request Sep 30, 2025
From CORTEX_MPU_M3_MPS2_QEMU_GCC remove unused configNUM_TX_DESCRIPTORS
define and remove HEAP3 from as heap_4.c is used.

Signed-off-by: Florian La Roche <[email protected]>
Co-authored-by: Rahul Kar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants