You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Segmentation fault when running in emulated amd64 container on M1 Mac #94909
This is a stripped down repro of Azure/bicep#10245, which has been reported by a number of our users trying to use a VSCode extension in an amd64 emulated devcontainer image.
It seems like the usage of Regex.Match is causing a segmentation fault when run in an amd64 image emulated on an M1 Mac.
Reproduction Steps
Open a bash prompt in an amd64 Docker container on an M1 Mac:
docker container run -it --platform=linux/amd64 mcr.microsoft.com/vscode/devcontainers/python:0-3.10-bullseye bash
Run the following to repro the issue:
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh --channel 7.0
git clone https://github.com/anthony-c-martin/dotnet-regex-rosetta-repro.git
cd dotnet-regex-rosetta-repro
/root/.dotnet/dotnet run
Thanks! I'll make sure we document that qemu is unsupported. It would be amazing if there's a way to detect this and warn the user (not sure how feasible however).
To make sure I'm understanding correctly, the following are both required to support the scenario:
Use Rosetta2 emulation (simplest option is to just upgrade to Docker desktop v4.25.0 or higher)
Set the DOTNET_EnableWriteXorExecute env var to 0
@stephentoub do you happen to have an explanation for why the env var is required? Is this to work around an issue in Rosetta2? Are you aware of any recommended approaches to detecting an emulated environment?
re: why DOTNET_EnableWriteXorExecute=0 is required... I have to guess that the running container can't tell Rosetta is involved. From #70912, it appears double mapping isn't supported when running in Rosetta. If we can't tell, then we'll take the x64 default.
Activity
vcsjones commentedon Nov 17, 2023
Setting
DOTNET_EnableWriteXorExecute=0fixes it:But I don't believe that is a stable work around. I am assuming this has something to do with double memory mapping.
If I am not mistaken, Docker uses QEMU emulation to run x86_64 on Apple Silicon, and .NET is not supported in QEMU.
sergiorru commentedon Nov 17, 2023
@vcsjones
Since docker version 4.25.0 the QEMU is not the default emulation used anymore, it's Rosetta2.
Using the workaround as you proposed (export DOTNET_EnableWriteXorExecute=0) worked for this sample.
Thank you!
stephentoub commentedon Nov 19, 2023
Yup, this was discussed here:
#78340 (comment)
anthony-c-martin commentedon Nov 27, 2023
Thanks! I'll make sure we document that qemu is unsupported. It would be amazing if there's a way to detect this and warn the user (not sure how feasible however).
To make sure I'm understanding correctly, the following are both required to support the scenario:
DOTNET_EnableWriteXorExecuteenv var to0@stephentoub do you happen to have an explanation for why the env var is required? Is this to work around an issue in Rosetta2? Are you aware of any recommended approaches to detecting an emulated environment?
mregen commentedon Dec 6, 2023
as a sidenote, I use the docker build in github actions here for .NET 8 armv8 docker build and the build issue was fixed by applying
in the Dockerfile
steveisok commentedon Jun 27, 2024
re: why
DOTNET_EnableWriteXorExecute=0is required... I have to guess that the running container can't tell Rosetta is involved. From #70912, it appears double mapping isn't supported when running in Rosetta. If we can't tell, then we'll take the x64 default.@jkotas does that sound right?
vcsjones commentedon Jun 27, 2024
Note that this will be better in .NET 9: #102509
jkotas commentedon Jun 27, 2024
Fixed by #102509