Fix concurrent Unix named mutex creation - #134111
Open
jkoritzinsky wants to merge 1 commit into
Open
jkoritzinsky wants to merge 1 commit into
jkoritzinsky wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @VSadov |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Add platform capability guards to prevent unsupported targets from failing or hanging.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Fixes a Unix named-mutex creation race by preserving the process lock through initial acquisition and ownership bookkeeping, with a concurrent regression test.
Changes:
- Updates Unix mutex acquisition locking.
- Adds concurrent initial-ownership coverage.
- Test requires platform capability guards for unsupported targets.
| File | Description |
|---|---|
src/libraries/System.Threading/tests/MutexTests.cs |
Adds concurrent named-mutex constructor coverage; requires guards for mobile, Browser, and Wasi. |
src/libraries/System.Private.CoreLib/src/System/Threading/NamedMutex.Unix.cs |
Preserves locking during nonblocking ownership setup. |
Comment on lines
+915
to
+916
| [Fact] | ||
| [PlatformSpecific(TestPlatforms.AnyUnix)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Why
Concurrent shared compilations on Linux can intermittently fail when a newly created named mutex is initially owned. The creator can lose the mutex between publishing the shared state and recording ownership, causing a later
ReleaseMutexto fail with "Cannot release a lock that is not owned by the current thread."What changed
Testing
./build.sh clr+libs -rc checked./build.sh clr.corelib+clr.nativecorelib+libs.pretest -rc checkeddotnet test src/libraries/System.Threading/tests/System.Threading.Tests.csproj --no-build(714 passed)Resolves #134043
Note
This pull request description was generated with GitHub Copilot assistance.