Skip to content

[runtime] Read __XAMARIN_DEBUG_CONNECTION_TIMEOUT__ on the main thread. - #27631

Open
rolfbjarne wants to merge 1 commit into
mainfrom
dev/rolf/capture-connection-timeout
Open

rolfbjarne wants to merge 1 commit into
mainfrom
dev/rolf/capture-connection-timeout

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

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 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 in xamarin_capture_debugging_settings on the main thread before the debugging thread starts, so do the same for this one.

Notes:

  • xamarin_capture_debugging_settings unsets __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 what XamarinDebugConnectTimeout sets (in Microsoft.Sdk.Mobile.targets and Microsoft.Sdk.Desktop.targets). So XamarinDebugConnectTimeout has 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.
  • Verified that the iOS simulator and device runtime objects build (monotouch-debug-dotnet-coreclr-debug.o for iossimulator-arm64 and ios-arm64, and monotouch-debug-dotnet-nativeaot.o); not tested at runtime.

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>
@rolfbjarne
rolfbjarne requested a review from dalexsoto as a code owner December 4, 2026 09:44
Copilot AI balanced review requested due to automatic review settings December 4, 2026 09:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 XamarinDebugConnectTimeout behavior unchanged.
File Description
runtime/​monotouch-debug.m Captures the timeout during startup and manages its lifetime during debugger configuration.

Review effort: Balanced

@MauiBot

MauiBot commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

🔥 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
Hash: [PR build]

@MauiBot

MauiBot commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

🔥 [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) tests

⚠️ Tests did not run because the Build macOS tests job failed.

Html Report (VSDrops) Download

❌ Tests on macOS Sequoia (15) tests

⚠️ Tests did not run because the Build macOS tests job failed.

Html Report (VSDrops) Download

❌ Tests on macOS Tahoe (26) tests

⚠️ Tests did not run because the Build macOS tests job failed.

Html Report (VSDrops) Download

❌ Tests on macOS Golden Gate (27) tests

⚠️ Tests did not run because the Build macOS tests job failed.

Html Report (VSDrops) Download

Successes

macOS tests

Linux Build Verification

✅ Linux build succeeded

Pipeline on Agent
Hash: 501f92cdd9ebb7542956debf5ba226fd120bdf15 [PR build]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants