Repository navigation
[runtime] Read __XAMARIN_DEBUG_CONNECTION_TIMEOUT__ on the main thread. - #27631
rolfbjarne wants to merge 1 commit into
Conversation
monotouch_configure_debugging runs on the debugging thread, and it read and unset __XAMARIN_DEBUG_CONNECTION_TIMEOUT__ there. Unsetting an environment variable while another thread reads the environment (for instance managed code on the main thread during startup) is a race that can crash. The other debug environment variables are already captured in xamarin_capture_debugging_settings on the main thread before the debugging thread starts; do the same for this one. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No actionable issues were found in the reviewed changes to runtime/monotouch-debug.m.
No open issues 🎉
What changed in this PR
Moves IDE connection-timeout environment handling to the main thread, avoiding a startup race with concurrent environment reads.
Changes:
- Captures and unsets
__XAMARIN_DEBUG_CONNECTION_TIMEOUT__before the debugging thread starts. - Uses the captured value during debugger configuration and frees it on normal and early-return paths.
- Leaves the separate
XamarinDebugConnectTimeoutbehavior unchanged.
| File | Description |
|---|---|
| runtime/monotouch-debug.m | Captures the timeout during startup and manages its lifetime during debugger configuration. |
Review effort: Balanced
|
🔥 Unable to find the contents for the comment: D:\a\1\s\change-detection\results\gh-comment.md does not exist :fire Pipeline on Agent |
🔥 [CI Build #501f92c] Test results 🔥Test results❌ Tests failed on VSTS: test results 29 tests crashed, 0 tests failed, 0 tests passed. Failures❌ assembly-processing tests🔥 Failed catastrophically on VSTS: test results - assembly-processing (no summary found). Html Report (VSDrops) Download ❌ cecil tests🔥 Failed catastrophically on VSTS: test results - cecil (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (iOS)🔥 Failed catastrophically on VSTS: test results - dotnettests_ios (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - dotnettests_maccatalyst (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (macOS)🔥 Failed catastrophically on VSTS: test results - dotnettests_macos (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (Multiple platforms)🔥 Failed catastrophically on VSTS: test results - dotnettests_multiple (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (tvOS)🔥 Failed catastrophically on VSTS: test results - dotnettests_tvos (no summary found). Html Report (VSDrops) Download ❌ framework tests🔥 Failed catastrophically on VSTS: test results - framework (no summary found). Html Report (VSDrops) Download ❌ fsharp tests🔥 Failed catastrophically on VSTS: test results - fsharp (no summary found). Html Report (VSDrops) Download ❌ generator tests🔥 Failed catastrophically on VSTS: test results - generator (no summary found). Html Report (VSDrops) Download ❌ interdependent-binding-projects tests🔥 Failed catastrophically on VSTS: test results - interdependent-binding-projects (no summary found). Html Report (VSDrops) Download ❌ introspection tests🔥 Failed catastrophically on VSTS: test results - introspection (no summary found). Html Report (VSDrops) Download ❌ linker tests (iOS)🔥 Failed catastrophically on VSTS: test results - linker_ios (no summary found). Html Report (VSDrops) Download ❌ linker tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - linker_maccatalyst (no summary found). Html Report (VSDrops) Download ❌ linker tests (macOS)🔥 Failed catastrophically on VSTS: test results - linker_macos (no summary found). Html Report (VSDrops) Download ❌ linker tests (tvOS)🔥 Failed catastrophically on VSTS: test results - linker_tvos (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (iOS)🔥 Failed catastrophically on VSTS: test results - monotouch_ios (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - monotouch_maccatalyst (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (macOS)🔥 Failed catastrophically on VSTS: test results - monotouch_macos (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (tvOS)🔥 Failed catastrophically on VSTS: test results - monotouch_tvos (no summary found). Html Report (VSDrops) Download ❌ msbuild tests🔥 Failed catastrophically on VSTS: test results - msbuild (no summary found). Html Report (VSDrops) Download ❌ sharpie tests🔥 Failed catastrophically on VSTS: test results - sharpie (no summary found). Html Report (VSDrops) Download ❌ windows tests🔥 Failed catastrophically on VSTS: test results - windows (no summary found). Html Report (VSDrops) Download ❌ xcframework tests🔥 Failed catastrophically on VSTS: test results - xcframework (no summary found). Html Report (VSDrops) Download ❌ xtro tests🔥 Failed catastrophically on VSTS: test results - xtro (no summary found). Html Report (VSDrops) Download ❌ Tests on macOS Sonoma (14) testsHtml Report (VSDrops) Download ❌ Tests on macOS Sequoia (15) testsHtml Report (VSDrops) Download ❌ Tests on macOS Tahoe (26) testsHtml Report (VSDrops) Download ❌ Tests on macOS Golden Gate (27) testsHtml Report (VSDrops) Download SuccessesmacOS testsLinux Build VerificationPipeline on Agent |
monotouch_configure_debuggingruns on the debugging thread, and it read and unset__XAMARIN_DEBUG_CONNECTION_TIMEOUT__there. Unsetting an environment variable while another thread reads the environment (for example managed code on the main thread during startup, which reads the environment when initializing globalization) is a data race that can crash the app.The other debug environment variables (
__XAMARIN_DEBUG_MODE__,__XAMARIN_DEBUG_PORT__,__XAMARIN_DEBUG_HOSTS__) are already captured inxamarin_capture_debugging_settingson the main thread before the debugging thread starts, so do the same for this one.Notes:
xamarin_capture_debugging_settingsunsets__XAMARIN_DEBUG_CONNECT_TIMEOUT__, which is a different variable: it was the Mono debugger's connect timeout (read there until the Mono runtime was removed in [runtime] Remove MonoVM-specific native runtime implementation #27064), and it's still whatXamarinDebugConnectTimeoutsets (inMicrosoft.Sdk.Mobile.targetsandMicrosoft.Sdk.Desktop.targets). SoXamarinDebugConnectTimeouthas no effect on the IDE connection timeout (__XAMARIN_DEBUG_CONNECTION_TIMEOUT__, added in [dotnet] Support 'dotnet watch' (Hot Reload) on physical devices. Fixes #25408 #26070). This PR doesn't change that.monotouch-debug-dotnet-coreclr-debug.oforiossimulator-arm64andios-arm64, andmonotouch-debug-dotnet-nativeaot.o); not tested at runtime.