-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Crash on Rosetta for double mapping jitted code #102226
Comments
Tagging subscribers to this area: @mangod9 |
Rosetta doesn't support the W^X double mapping. It's disabled on macOS when running under Rosetta. I am not sure if it's possible to detect it under linux-arm64 container/VM. |
I think it could be acceptable, since if we detected that automatically somehow in the runtime, we would do the same thing as setting that env variable would do. But I'd look if there is a way to detect that we are running in linux container on mac. |
I don't think Roblox cares whether W^X is enabled or not as long as the app doesn't crash. Now that they know about the env var I suspect this is only a small inconvenience for them, but they are reporting it for the benefit of others who might run into the same thing. My main worries here would be:
|
Thinking about it more, I need to refresh my mind on what exactly happens when we try to double map under rosetta. I believe I have it recorded in my notes somewhere. If that was something we can reliably test at startup and figure out it doesn't work, we can use that instead of trying to figure out if a linux container is running on rosetta. |
Ah, found it. The problem is that when a code is modified in memory via a secondary mapping and the preexisting code in the same page was already executed before, rosetta basically ignores the modifications. It doesn't detect that it needs to recompile the code on that page from x64 to arm64 again. I guess this would be detectable by creating a page with some code that e.g. returns a constant. Then modifying the code via double mapping to code that returns a different constant, calling that code and checking the result. |
The docker on macOS Arm64 uses Rosetta to run x64 containers. That has an effect on the double mapping. The Rosetta is unable to detect when an already executed code page is modified. So we cannot use double mapping on those containers. To detect that case, this change adds check that verifies that the double mapping works even when the code is modified. Close dotnet#102226
* Disable W^X on x64 in rosetta based container The docker on macOS Arm64 uses Rosetta to run x64 containers. That has an effect on the double mapping. The Rosetta is unable to detect when an already executed code page is modified. So we cannot use double mapping on those containers. To detect that case, this change adds check that verifies that the double mapping works even when the code is modified. Close #102226 * Rework based on PR feedback * Check only for Rosetta * Enable the rosetta check for x86 too This will help WINE running 32 bit code under rosetta emulation on macOS.
* Disable W^X on x64 in rosetta based container The docker on macOS Arm64 uses Rosetta to run x64 containers. That has an effect on the double mapping. The Rosetta is unable to detect when an already executed code page is modified. So we cannot use double mapping on those containers. To detect that case, this change adds check that verifies that the double mapping works even when the code is modified. Close dotnet#102226 * Rework based on PR feedback * Check only for Rosetta * Enable the rosetta check for x86 too This will help WINE running 32 bit code under rosetta emulation on macOS.
The docker on macOS Arm64 uses Rosetta to run x64 containers. That has an effect on the double mapping. The Rosetta is unable to detect when an already executed code page is modified. So we cannot use double mapping on those containers. To detect that case, this change adds check that verifies that the double mapping works even when the code is modified. Close #102226
…on macOS (#105117) * Disable W^X on x64 in rosetta based container The docker on macOS Arm64 uses Rosetta to run x64 containers. That has an effect on the double mapping. The Rosetta is unable to detect when an already executed code page is modified. So we cannot use double mapping on those containers. To detect that case, this change adds check that verifies that the double mapping works even when the code is modified. Close #102226 * Rework based on PR feedback * Check only for Rosetta * Enable the rosetta check for x86 too This will help WINE running 32 bit code under rosetta emulation on macOS. --------- Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
The docker on macOS Arm64 uses Rosetta to run x64 containers. That has an effect on the double mapping. The Rosetta is unable to detect when an already executed code page is modified. So we cannot use double mapping on those containers. To detect that case, this change adds check that verifies that the double mapping works even when the code is modified. Close #102226
…#106353) * Disable W^X on x64 in rosetta based container The docker on macOS Arm64 uses Rosetta to run x64 containers. That has an effect on the double mapping. The Rosetta is unable to detect when an already executed code page is modified. So we cannot use double mapping on those containers. To detect that case, this change adds check that verifies that the double mapping works even when the code is modified. Close #102226 * Rework based on PR feedback * Check only for Rosetta * Enable the rosetta check for x86 too This will help WINE running 32 bit code under rosetta emulation on macOS. --------- Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
Description
Roblox reported that their app crashes when run in Rosetta unless they set DOTNET_EnableWriteXorExecute=0
Reproduction Steps
docker run --platform linux/amd64 -it docker.artifactory.rbx.com/dotnet/sdk:8.0 /bin/bash
root@361134e3e399:/# dotnet new tool-manifest
Expected behavior
No crash
Actual behavior
Segmentation fault
Regression?
Unknown
Known Workarounds
set DOTNET_EnableWriteXorExecute=0
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: