Skip to content

Fix SOS managed hosting on macOS - #6243

Merged
steveisok merged 2 commits into
mainfrom
steveisok-sos-macos-lldb-hosting-fix
Nov 14, 2026
Merged

steveisok merged 2 commits into
mainfrom
steveisok-sos-macos-lldb-hosting-fix

Conversation

@steveisok

Copy link
Copy Markdown
Member

Summary

SOS can be killed when CoreCLR replaces Apple LLDB's guarded Mach exception ports. With that avoided, an automatically selected .NET 10 host can still fail initialization with 0x8007000C, even when a working .NET 11 runtime is installed alongside it.

  • Default PAL_MachExceptionMode to 7 on macOS without replacing an explicit user value.
  • If an automatically selected .NET 10 runtime fails coreclr_initialize, retry once with .NET 11 from the same installation. Preserve DOTNET_ROOT precedence and explicit sethostruntime paths. Keep the existing probing helpers and runtime order unchanged; Windows/Linux behavior is unchanged.
  • Add focused Apple LLDB regression tests using a prebuilt failing-runtime fixture, stage the fixture in the Helix payload, and document the behavior.

Validation

  • ./build.sh -skipmanaged -configuration Release -architecture arm64 passed.
  • ./.dotnet/dotnet build src/tests/SOS.Tests/SOS.Tests.csproj -c Release --no-restore -p:TargetArch=arm64 -p:TargetRid=osx-arm64 passed.
  • Focused configuration/hosting suite: 36 tests passed, covering successful recovery, missing/failing .NET 11, no retry for other initial runtime versions, and explicit runtime/environment overrides.
  • On macOS 27.2 ARM64, Apple LLDB started without a PAL_MachExceptionMode override, recovered from the real .NET 10.0.9 initialization failure, and hosted SOS on .NET 11.0.0.
  • Manual dump inspection passed for JIT (sosstatus, clrthreads, clrstack) and NativeAOT (sosstatus, clrthreads, including the expected System.NullReferenceException). NativeAOT validation used a separately provisioned matching managed-extension/cDAC payload with the rebuilt native SOS libraries.

Windows/Linux execution was not performed locally.

Default PAL_MachExceptionMode to 7 on macOS without replacing user settings.

When an automatically selected .NET 10 host fails initialization, retry
once with .NET 11 from the same installation. Preserve explicit runtime
paths, DOTNET_ROOT precedence, and other platforms' probing behavior.

Add focused Apple LLDB regression tests using a prebuilt failing runtime
fixture, include it in the Helix payload, and document the fallback.

Co-authored-by: Copilot App <[email protected]>
@steveisok
steveisok requested a review from a team as a code owner November 14, 2026 00:10
Comment thread src/SOS/extensions/hostcoreclr.cpp Resolved

@tommcdon tommcdon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left a comment for your review, otherwise LGTM

Match the unique test directory and runtime suffix rather than the parent path, which macOS canonicalizes from /tmp to /private/tmp.

Co-authored-by: Copilot App <[email protected]>
@steveisok

Copy link
Copy Markdown
Member Author

ChildProcessTests.VerifyShowIO is timing out on win-x86 and is unrelated.

@steveisok

Copy link
Copy Markdown
Member Author

/ba-g Unrelated ChildProcessTests.VerifyShowIO timeout on x86 runs.

@steveisok
steveisok enabled auto-merge (squash) November 14, 2026 15:59
@steveisok
steveisok merged commit abc209d into main Nov 14, 2026
22 of 24 checks passed
@steveisok
steveisok deleted the steveisok-sos-macos-lldb-hosting-fix branch November 14, 2026 16:00
hoyosjs added a commit that referenced this pull request Nov 14, 2026
SOS now prefers .NET 11 over .NET 10 on all platforms, avoiding a .NET
10 hosting failure under Apple LLDB. This replaces the retry added in
#6243; retrying after initialization fails is unnecessary when .NET 11
can be selected first. The PAL_MachExceptionMode default is preserved.

Manually verified with Apple LLDB attached to a .NET 10 process: SOS
hosted on .NET 11, and managed inspection commands succeeded.

Co-authored-by: Copilot App <[email protected]>
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