Repository navigation
Fix hangdump on macOS - #7005
Merged
Merged
Conversation
Youssef Fahmy (Youssef1313)
force-pushed
the
dev/ygerges/addtest-hangdump
branch
2 times, most recently
from
November 28, 2025 20:36
d3142b1 to
dc981f9
Compare
Youssef Fahmy (Youssef1313)
force-pushed
the
dev/ygerges/addtest-hangdump
branch
from
November 28, 2025 20:38
a61b165 to
d8c09d7
Compare
Marco Rossignoli (MarcoRossignoli)
approved these changes
Nov 29, 2025
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.
Today, we use mutex for the interprocess communication between test host and test host controller. The flow goes as follow:
This flow works well on Windows, but never works well on macOS. What we see on macOS is that the test host always gets the ownership of the mutex. Here, the test host releases the mutex and re-requests its ownership again. The test host controller is also requesting ownership of the mutex. Due to implementation differences of named mutex in .NET between Windows and macOS, what we see on Windows is that the ownership always gets swapped. But on macOS, it can happen that only the test host is always getting the ownership. This means that we end up in a situation where hang dump will be detected but no actual hang is happening.
This PR changes the implementation to avoid the use of a named mutex altogether, which also has problems on Mono and NativeAOT -> dotnet/runtime#110348.
The new implementation relies on named pipe and a timer. Whenever the test host has activity, we send that through named pipe to the test host controller. The test host controller keeps resetting a timer when activity is received. When the timer callback fires, we start taking a dump.
Note: to my best guess, macOS has very different mutex implementation that uses file locks. See https://github.com/dotnet/runtime/blob/c3d9ccd34e63d7b383735af55c9bd94f55664996/src/coreclr/pal/src/include/pal/mutex.hpp#L129-L130
This PR fixes the root cause of #6998, but keeping that issue open until this PR flows to main and we bring back hangdump on macOS.