Fix broken debugger/debuggee startup handshake protocol on macOS26. #5530
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.
As identified by dotnet/runtime#116545, macOS26 have broken semaphores in case debugger and debuggee have been signed with different team ids, currently only mentioned for iOS/iPadOS, https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-26-release-notes, but testing shows its broken for regular apps as well.
This PR adds support for a different startup handshake protocol for debugger/debuggee using FIFO file (aka named pipes) on Apple platforms due to limitation introduced in macOS26. All other POSIX platforms will continue to use the semaphore based handshake protocol.
The implementation is backward compatible on Apple platforms. Implementation will always setup semaphores to support runtimes using semaphore protocol, but on Apple platforms it will also create the new FIFO files, it will then spawn a separate background thread checking the FIFO files for connections and handling the protocol. In case runtime supports new FIFIO based protocol, background thread will handle complete protocol and signal/wait semaphores, making the underlying protocol transparent for the startup thread, it will always use the semaphores. In case runtime doesn't support FIFO files, runtime will signal/wait on the semaphores as normal coordinating with the debugger startup thread. In the case runtime doesn't support FIFO files, the background thread will just sit and wait on connections until canceled. Unregister cancel out background thread in case runtime didn't support FIFO files.
Since this fix supports both semaphores and FIFO files on Apple platform it is compatible with old runtimes using semaphores as well as new runtimes that supports the FIFO based handshake protocol.
In order for this change to work E2E, the debugger needs to use changes introduced in this PR with a runtime including dotnet/runtime#118120. Until both debugger and debuggee have been update, debug launch on macOS26 won't work.
Names of the two new FIFO files follow the same naming pattern as we have for existing debugger FIFO's, using suffix currently used for the startup and continue semaphores, "st" for startup and "co" for continue, example of full FIFO names:
/var/folders/d0/l_56x0lx6l7bbrv3pfr128xc0000gn/T/clr-debug-pipe-11462-1753451225-st
/var/folders/d0/l_56x0lx6l7bbrv3pfr128xc0000gn/T/clr-debug-pipe-11462-1753451225-co