-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Illegal memory double mapping on Apple Silicon using Rosseta emulation #106819
Comments
This was already fixed in .NET 9 by #102509 and fixed in .NET 8 servicing. Am I missing something? |
Missed that specific fix in my research, looking at the change log it appears the premises described in other information is still accurate as the The runtime/src/coreclr/utilcode/executableallocator.cpp does not check if rosseta is being used when determining if double mapping is enabled. There appears to be race condition with the check to disable W^X as the repo reliability crashes until explicitly disabling the feature with env flag. runtime/src/coreclr/utilcode/executableallocator.cpp Lines 286 to 291 in 6177a9f
|
Tagging subscribers to this area: @mangod9 |
Is the .NET 8 backport in the current LTS or an upcoming one? I could test a build with #102509. |
The 8.0 backport was only merged last week, so it’s not part of 8.0.8 release yet. |
correct should be included in 8.0.9. Can you try your scenario on .NET 9 to ensure its the same issue? |
Running with the nightly .NET 9 I can confirm the issue has been fixed by #102509. Thank you all for your time and appreciate the backport! |
Description
As part of adding W^X (write xor execute) support #54954 memory double mapping was implemented that is unsupported by Apple Silicon, including emulating AMD64 using Rosseta. A patch to fix this #70912 was incomplete and results in memory related crashes running .NET 8 as a result of feature being enabled by default.
Reproduction Steps
Importantly, to reproduce requires a Mac with Apple Silicon and Docker Desktop for Mac with "Use Rosetta for x86_64/amd64 emulation on Apple Silicon" enabled (or any other containerization of Linux AMD64 using Rosetta).
A complete reproduction can be found at https://github.com/Yukon/Dotnet-WriteXorExecuteCrash that includes a Dockerfile to quickly reproduce.
A simple reproduction is inserting into a
ConcurrentDictionary<string, bool>
.Expected behavior
Application executes without throwing exceptions or crashing.
Actual behavior
For the complete reproduction provided the application with either segfault with exit code 139 or will throw:
Additional symptoms related to this issue and others (#97828 , #100539),
dotnet restore hangs
When running
dotnet restore
the process will hang and never complete.assertion failed [block != nullptr]
Application outputs to console and crashes with exit code 133.
Regression?
Regressed in .NET 7 when W^X was enabled by default #69672.
Known Workarounds
Disabling W^X stops all double mapping from occurring.
runtime/src/coreclr/utilcode/executableallocator.cpp
Lines 123 to 132 in 6177a9f
Set the environment variable
DOTNET_EnableWriteXorExecute
to0
before running the application.Configuration
Other information
Double mapping is not supported in Apple Silicon using Rosetta, which was intended to be fixed in #70912. This is not completely the case though as the emulation check occurs in the underlying
doublemapping.cpp
not in the allocator that has theIsDoubleMappingEnabled
check. This gap results in double mapping being implied it is enabled resulting in inappropriate memory calls in the allocator as well as double mapping methods without theIsProcessTranslated
guard clause.By disabling W^E the
IsDoubleMappingEnabled
method always returns false, preventing any double mapping from occurring.The text was updated successfully, but these errors were encountered: