Skip to content

Conversation

@rolfbjarne
Copy link
Member

@rolfbjarne rolfbjarne commented Jul 15, 2022

There's a bug in the Mono runtime where the interpreter does not disable optimizations when the debugger is attached, which leads to the interpreter optimizing code and the debugger ending up rather confused.

The bug is fixed in the Mono runtime (dotnet/runtime#71436), but there's no immediate way for the runtime to release this fix, so here we're implementing a workaround that disables interpreter optimizations if the debugging is enabled. It's somewhat clunky because the Mono external API wasn't designed for this, so we have to abuse the API a bit to accomplish the effect we want.

This is somewhat risky (since we're changing the startup path in a pretty big way), but there's an escape hatch via an environment variable, and also the workaround will not be in effect for release builds.

While the runtime issue exists in legacy mono/mono as well, we'll fix the Mono runtime for legacy, because we don't have to wait to consume legacy mono (#15507). This means that the workaround is for .NET scenarios only.

This is a backport of ##15451.

There's a bug in the Mono runtime where the interpreter does not disable optimizations when the debugger is attached, which leads to the interpreter optimizing code and the debugger ending up rather confused.

The bug is fixed in the Mono runtime (dotnet/runtime#71436), but there's no immediate way for the runtime to release this fix, so here we're implementing a workaround that disables interpreter optimizations if the debugging is enabled. It's somewhat clunky because the Mono external API wasn't designed for this, so we have to abuse the API a bit to accomplish the effect we want.

This is somewhat risky (since we're changing the startup path in a pretty big way), but there's an escape hatch via an environment variable, and also the workaround will not be in effect for release builds.

While the runtime issue exists in legacy mono/mono as well, we'll fix the Mono runtime for legacy, because we don't have to wait to consume legacy mono (dotnet#15507). This means that the workaround is for .NET scenarios only.

This is a backport of #dotnet#15451.
@rolfbjarne rolfbjarne added the bug If an issue is a bug or a pull request a bug fix label Jul 15, 2022
@rolfbjarne rolfbjarne changed the title [debugger] Work around a debugger issue when using the interpreter. [release/6.0.3xx] [debugger] Work around a debugger issue when using the interpreter. Jul 15, 2022
@vs-mobiletools-engineering-service2
Copy link
Collaborator

📚 [PR Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMBOT-1036.Monterey'
Hash: 441ed56855ecc1ca9f6a6a7e7e44707347a85edf

@vs-mobiletools-engineering-service2
Copy link
Collaborator

📋 [PR Build] API Diff 📋

API Current PR diff

✅ API Diff (from PR only) (no change)

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

API diff

✅ API Diff from stable

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

Generator diff

Generator Diff (no change)

Pipeline on Agent XAMBOT-1023.Monterey'
Hash: 441ed56855ecc1ca9f6a6a7e7e44707347a85edf

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [PR Build] Tests on macOS Mac Catalina (10.15) passed 💻

All tests on macOS Mac Catalina (10.15) passed.

Pipeline on Agent
Hash: 441ed56855ecc1ca9f6a6a7e7e44707347a85edf

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌

Failed tests are:

  • introspection
  • xammac_tests
  • monotouch-test

Pipeline on Agent
Hash: 441ed56855ecc1ca9f6a6a7e7e44707347a85edf

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build] Tests passed on VSTS: simulator tests iOS. ✅

Tests passed on VSTS: simulator tests iOS.

Test results

# Test run in progress: Building: 19, BuildQueued: 90, Running: 4, RunQueued: 2, Succeeded: 29, Ignored: 1237, BuildFailure: 3

Failed tests

  • link sdk/Mac [dotnet]/Debug [dotnet]: BuildFailure
  • link sdk/Mac Catalyst [dotnet]/Release [dotnet]: BuildFailure
  • link all/Mac Catalyst [dotnet]/Debug [dotnet]: BuildFailure

Pipeline on Agent XAMBOT-1039.Monterey'
Merge 441ed56 into 6f1fd63

@dalexsoto
Copy link
Member

@dalexsoto dalexsoto merged commit f7bb07e into dotnet:release/6.0.3xx Jul 18, 2022
@dalexsoto dalexsoto deleted the 6.0.3xx-debugger-interpreter-workaround branch July 18, 2022 14:23
rolfbjarne added a commit to rolfbjarne/macios that referenced this pull request Aug 31, 2022
…reter. (dotnet#15509)". Fixes dotnet#15585.

This reverts commit f7bb07e.

This workaround is no longer needed, since the dotnet/runtime hash we're using
contains this fix.

Fixes dotnet#15585.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug If an issue is a bug or a pull request a bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants