Skip to content

Use private executable-template mappings under Rosetta - #136289

Merged
janvorli merged 1 commit into
mainfrom
dev/rolf/rosetta-template-remap
Oct 30, 2026
Merged

janvorli merged 1 commit into
mainfrom
dev/rolf/rosetta-template-remap

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

CoreCLR's template allocator bypasses the existing restriction on shared executable mappings under Rosetta. Shared vm_remap aliases can leave Rosetta repeatedly faulting in its AOT translation-cache list during x64 startup, preventing managed code from running.

Request copy-on-write mappings when Rosetta is detected, retaining the existing image-backed executable protections and preserving shared mappings for native execution. This changes the problematic mapping itself rather than masking the startup hang with retries, timeout increases, or disabled AOT.

The exact-revision unmodified native build reproduced the fault on launch 8. The source-built change passed 100 uninstrumented minimal-host launches; forcing only its remap copy argument back to FALSE reproduced the same native fault on launch 7, and removing that intervention passed another 100 launches.

The standalone net11.0 Hello World app from the issue also reproduces using the failing .NET 12 runtime, without macios or custom native code. Replacing only its libcoreclr.dylib with the fixed runtime passed 200 launches. The original repeated macios Debug and Release cases passed all 80 application launches. These investigation results were collected against the runtime revision from the failing package, before rebasing this fix onto current main.

After rebasing onto main at 132d07183975d2846b0252c4dc9fabcb85bcba61, the x64 Release CoreCLR build succeeded with no warnings or errors. The same standalone app passed another 200 launches using the rebased build's CoreCLR, JIT, and CoreLib, with the original 30-second timeout and Rosetta AOT enabled.

The new detection check runs when allocating a template block, not when executing a stub. A native allocation/remap/free microbenchmark under Rosetta (five runs, each with 30 alternating baseline/candidate pairs and 20,000 allocations per phase) showed no consistent slowdown: median allocation-cycle times were approximately 4.3 us baseline and 4.4 us candidate, with run-to-run variation larger than that difference. The detection call itself measured approximately 25 ns under Rosetta and 1 ns on native ARM64. These measurements do not execute the remapped templates or measure Rosetta translation costs, end-to-end application performance, or native Intel performance.

Resolves #136288

Note

This pull request description was prepared with GitHub Copilot.

CoreCLR's template allocator bypasses the existing restriction on shared executable mappings under Rosetta. Shared vm_remap aliases can leave Rosetta repeatedly faulting in its AOT translation-cache list during x64 startup, preventing managed code from running.

Request copy-on-write mappings when Rosetta is detected, retaining the existing image-backed executable protections and preserving shared mappings for native execution. This changes the problematic mapping itself rather than masking the startup hang with retries, timeout increases, or disabled AOT.

The exact-revision unmodified native build reproduced the fault on launch 8. The source-built change passed 100 uninstrumented minimal-host launches; forcing only its remap copy argument back to FALSE reproduced the same native fault on launch 7, and removing that intervention passed another 100 launches.

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

Copilot-Session: d6bbfaee-7acb-41c6-ad60-06713a457a09
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke
See info in area-owners.md if you want to be subscribed.

@jkotas jkotas added the os-ios Apple iOS label Oct 22, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

@vitek-karas
vitek-karas requested a review from janvorli October 23, 2026 09:15
rolfbjarne added a commit to dotnet/macios that referenced this pull request Oct 28, 2026
Ignore dotnet unit tests at the shared `TestBaseClass.CanExecute` check when an x64 executable would run through Rosetta, pointing to tracking issue #27034. Intermittent runtime startup hangs are blocking PR validation while the upstream fix is pending.

Keep native Intel execution and ARM64-capable universal apps on native ARM64 test runners enabled. Also cover translated x64 test runners while preserving the existing Windows and simulator behavior. Affected cases are marked ignored rather than merely returning false from the execution check.

This is a temporary CI mitigation, not the runtime root-cause fix. Track removal of the ignore after the fixed runtime is adopted and verified in #27034; the upstream fix is dotnet/runtime#136289.

Related: #27034

🤖 Pull request created by Copilot

@janvorli janvorli 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.

LGTM, thank you!

@janvorli
janvorli merged commit 6283b2b into main Oct 30, 2026
113 checks passed
@janvorli
janvorli deleted the dev/rolf/rosetta-template-remap branch October 30, 2026 20:37
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 4, 2026
@akoeplinger

Copy link
Copy Markdown
Member

should this be backported to 11.0?

@rolfbjarne

Copy link
Copy Markdown
Member Author

should this be backported to 11.0?

I haven't seen this in .NET 11 so far, only .NET 12.

I think the best option would be to wait with backporting until we have concrete evidence it's actually a problem in .NET 11.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[macOS/Rosetta] .NET 12 x64 console startup intermittently hangs in translation cache; private template mappings avoid it

4 participants