-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix broken debugger/debuggee startup handshake protocol on macOS26. #118120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix broken debugger/debuggee startup handshake protocol on macOS26. #118120
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a workaround for broken semaphore functionality in macOS 26 where semaphores fail when debugger and debuggee are signed with different team ids. The solution introduces an alternative handshake protocol using FIFO files (named pipes) while maintaining backward compatibility with the existing semaphore-based approach.
Key changes:
- Adds FIFO-based runtime startup handshake protocol for Apple platforms
- Implements backward compatibility by attempting FIFO first, then falling back to semaphores
- Refactors existing semaphore logic into a separate function for better code organization
Matching diagnostics PR, dotnet/diagnostics#5530. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Left a comment for your review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
…5530) 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
/backport to release/9.0-staging |
/backport to release/8.0-staging |
Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/16627176985 |
Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/16627180419 |
…protocol on macOS26. (#118213) Backport of #118120 * Add support for new startup handshake protocol over pipes instead of sempahores. * Remove NonBlocking runtime support. * Renames, logging and simplification. * Improve tracing. * Make open check non blocking. * Fold access into open calls and track ENOENT | ENOACCES * Review feedback. --------- Co-authored-by: lateralusX <[email protected]>
As identified by #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. First it will check for new FIFO files, if not found, it will fallback to semaphores, making sure old debugger implementation will continue to work as is even if runtime supports new handshake protocol. It will be the debugger that decides what protocol version to use, runtime will continue working with both versions of the protocol. This also makes this PR standalone from the corresponding change in debugger (dbgshim), so debugger should continue to work on Apple platforms (except macOS26) with old dbgshim.
In order for this change to work E2E, the debugger needs to use a new dbgshim implementing updated startup handshake protocol, dotnet/diagnostics#5530. 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