Repository navigation
Conversation
Concurrent Mach thread state queries can deadlock when an x64 process runs under Rosetta. Serialize the Apple process-wide barrier only in translated processes and add a concurrent-call regression test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6de45ab0-f614-494b-9fcf-b38d01823145
|
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
The regression test must skip when multithreading is unsupported.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
This PR serializes process-wide memory barriers under Rosetta to prevent concurrent Mach-state query deadlocks and adds regression coverage.
Changes:
- Adds Rosetta-specific mutex serialization.
- Adds a concurrent four-thread barrier test.
| File | Description |
|---|---|
src/native/minipal/memorybarrierprocesswide.c |
Serializes barrier calls under Rosetta. |
src/libraries/System.Threading/tests/InterlockedTests.cs |
Adds concurrent barrier regression coverage. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This branch has not been deployed
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.

Summary
Interlocked.MemoryBarrierProcessWideconcurrently from four threads.Motivation
Under Rosetta, concurrent calls to
thread_get_register_pointer_valuescan deadlock while reconstructing translated x64 thread state. A standalone stress repro hung in 5 out of 5 runs, with every worker blocked in:Serializing the existing Mach-based barrier avoids this deadlock while retaining the mechanism recommended for Apple platforms.
This addresses the concurrent-barrier hang reported in #133797. It intentionally does not add a
pthread_atforkhandler for the separate raw-forkinteraction. Normal .NET process creation on macOS usesposix_spawnafter #126063.Validation
./build.sh clr+libs+host./build.sh clr+libs+host./build.sh clr+libs+host -arch x64 -cross./build.sh clr.native -c Release./build.sh clr.native -c Release -arch x64 -crossSystem.Threading.Tests: 714 passed on native arm64System.Threading.Tests: 714 passed on x64 under Rosettalibcoreclr; it completes in about 5.5 seconds with the fixPerformance
Single-threaded
Interlocked.MemoryBarrierProcessWidelatency was measured using a Debug x64 testhost under Rosetta, taking the median of 10 process runs with 10,000 calls per run:The uncontended mutex adds approximately 2% in this configuration. Concurrent calls are intentionally serialized because issuing the Mach register-state queries concurrently is the operation that deadlocks Rosetta.
Note
This pull request description was generated with GitHub Copilot.