Repository navigation
Segfault in amd64 container using Rosetta #6773
Copy link
Copy link
Closed
Description
- [x ] I have tried with the latest version of Docker Desktop
- [x ] I have tried disabling enabled experimental features
- [x ] I have uploaded Diagnostics
- Diagnostics ID: 2381464F-94BB-4A0B-B72F-0C88910859D5/20230321150015
Expected behavior
Expected amd64 containers run under Rosetta to function the same as containers run under QEMU.
Actual behavior
amd64 containers run under Rosetta segfaults.
Information
- macOS Version: 13.2.1
- Intel chip or Apple chip: M1 arm64
- Docker Desktop Version: 4.17.0 (99724)
Output of /Applications/Docker.app/Contents/MacOS/com.docker.diagnose check
For the record: Docker is running and working fine; no idea why diagnose is reporting the VM down.
[2023-03-21T15:04:20.693017000Z][com.docker.diagnose][I] set path configuration to OnHost
Starting diagnostics
[PASS] DD0027: is there available disk space on the host?
[PASS] DD0028: is there available VM disk space?
[PASS] DD0018: does the host support virtualization?
[PASS] DD0001: is the application running?
[FAIL] DD0017: can a VM be started? vm has not started: vm has not started
[FAIL] DD0016: is the LinuxKit VM running? vm is not running: vm has not started
[PASS] DD0011: are the LinuxKit services running?
[PASS] DD0004: is the Docker engine running?
[PASS] DD0015: are the binary symlinks installed?
[PASS] DD0031: does the Docker API work?
[PASS] DD0013: is the $PATH ok?
[PASS] DD0003: is the Docker CLI working?
[PASS] DD0038: is the connection to Docker working?
[PASS] DD0014: are the backend processes running?
[PASS] DD0007: is the backend responding?
[PASS] DD0008: is the native API responding?
[PASS] DD0009: is the vpnkit API responding?
[PASS] DD0010: is the Docker API proxy responding?
[SKIP] DD0030: is the image access management authorized?
[PASS] DD0033: does the host have Internet access?
[PASS] DD0018: does the host support virtualization?
[PASS] DD0001: is the application running?
[WARN] DD0017: can a VM be started? vm has not started: vm has not started
[WARN] DD0016: is the LinuxKit VM running? vm is not running: vm has not started
[PASS] DD0011: are the LinuxKit services running?
[PASS] DD0004: is the Docker engine running?
[PASS] DD0015: are the binary symlinks installed?
[PASS] DD0031: does the Docker API work?
[PASS] DD0032: do Docker networks overlap with host IPs?
Please note the following 2 warnings:
1 : The check: can a VM be started?
Produced the following warning: vm has not started: vm has not started
The Docker engine runs inside a Linux VM. Therefore we must be able to start Virtual Machines.
2 : The check: is the LinuxKit VM running?
Produced the following warning: vm is not running: vm has not started
The Docker engine runs inside a Linux VM. Therefore the VM must be running.
Please investigate the following 1 issue:
1 : The test: can a VM be started?
Failed with: vm has not started: vm has not started
The Docker engine runs inside a Linux VM. Therefore we must be able to start Virtual Machines.
Immediately after running the above command, I ran:
$ docker run --rm hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(arm64v8)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
Steps to reproduce the behavior
Using this code/Dockerfile, which has a very simple build of a golang file being added to a distroless base image.
From an Apple Silicon machine, run: docker buildx build -t koehn/fetchurl --platform linux/amd64,linux/arm64 . --push with Rosetta enabled, then without. For me, the without version segfaults:
#21 [linux/amd64 build 5/5] RUN go build -o /go/bin/fetchurl && upx --brute /go/bin/fetchurl
456
#21 32.80 crypto/md5: /usr/local/go/pkg/tool/linux_amd64/asm: signal: segmentation fault
129s
457
#21 49.00 vendor/golang.org/x/net/http/httpproxy: /usr/local/go/pkg/tool/linux_amd64/compile: signal: segmentation fault
145s
458
#21 ERROR: process "/dev/.buildkit_qemu_emulator /bin/sh -c go build -o /go/bin/fetchurl && upx --brute /go/bin/fetchurl" did not complete successfully: exit code: 1
147s
459
------
460
> [linux/amd64 build 5/5] RUN go build -o /go/bin/fetchurl && upx --brute /go/bin/fetchurl:
461
#21 32.80 crypto/md5: /usr/local/go/pkg/tool/linux_amd64/asm: signal: segmentation fault
462
#21 49.00 vendor/golang.org/x/net/http/httpproxy: /usr/local/go/pkg/tool/linux_amd64/compile: signal: segmentation fault
463
------
464
Dockerfile:8
465
--------------------
466
7 |
467
8 | >>> RUN go build -o /go/bin/fetchurl && \
468
9 | >>> upx --brute /go/bin/fetchurl
469
10 |
470
--------------------
471
ERROR: failed to solve: process "/dev/.buildkit_qemu_emulator /bin/sh -c go build -o /go/bin/fetchurl && upx --brute /go/bin/fetchurl" did not complete successfully: exit code: 1
472
time="2023-03-21T14:29:53Z" level=error msg="execution failed: exit status 1”
Again, when I disable Rosetta and run the build again, it succeeds. The arm64 build always succeeds.
Reactions are currently unavailable
Activity
Otterverse commentedon May 5, 2023
I have the same issue when using UPX to compress a binary (and it just so happens to be a Go language produced binary too.) UPX definitely does some strange things to a binary, but as it still works under the old qemu system, it does seem to be a rosetta specific issue.
LaurentLesle commentedon May 30, 2023
Getting the same when using docker buildx build --platform linux/amd64 on MacOS M1
I am fixing the issue by disabling the use of Rosetta but it is much much slower.
koehn commentedon Jul 13, 2023
Just checking in to see if anyone is listening… still getting segfaults using Rosetta on Docker 4.21.1 (114176)/MacOS Ventura 13.4.1 (22F82).
reypm commentedon Aug 16, 2023
I have tried the following versions:
and still getting the same error:
I am running macOS Ventura 13.5. This is driving me crazy since I cannot find a solution for this issue, any help?
zerok commentedon Nov 8, 2023
Can also reproduce this on macOS 14.1 with Docker For Mac 4.25.0. This is especially problematic as Rosetta is now enabled by default.
Just to add another example of what fails: https://github.com/zerok/docker-rosetta-issue
AlekSi commentedon Nov 8, 2023
It might be related to docker/buildx#2028
koehn commentedon Nov 8, 2023
I recently learned that you can create a builder in
buildxthat uses multiple machines with Docker installed using e.g., ssh. When you run a multi-platform build using that builder, buildx sends builds to native hardware whenever possible, avoiding this issue.You can include pods running on a Kubernetes cluster as well.
See
docker buildx --appendfor more details.I don’t know if this is a bug in Rosetta, Docker, or QEMU, but in the meantime I have fast builds that work.
AdrienPoupa commentedon Nov 20, 2023
We are getting a segmentation fault with a Ubuntu-based image running PHP-FPM and Composer:
Anything we can do to report the issue?
This has always been happening on my end, and is more annoying since the option got enabled by default (currently using 4.25.1)
dgageot commentedon Nov 21, 2023
Hi @zerok, I've tried to reproduce from your project but couldn't make it fail. Could you share the exact commands you used to trigger the issue?
dgageot commentedon Nov 21, 2023
Hi @AdrienPoupa, could you share the exact commands you used to trigger the issue? Which version of php are you using? Have you tried with a more recent version?
dgageot commentedon Nov 21, 2023
@koehn same, I couldn't reproduce with your project.
FWIW, I'm on Sonoma 14.1.1 and Docker Desktop 4.25.1
zerok commentedon Nov 21, 2023
Hi @dgageot 🙂 A checkout of that repository and then running
go run .should produce the segfault (or a different cgo exit error, that's somehow not deterministic yet).Happened for me with 4.25.0 (126437) every time I ran it.
With 4.25.1 the story is a bit different. I had to run the same command multiple times but in the vast majority of runs I now see this:
... or similar errors.
I'm also on macOS 14.1.1.
dgageot commentedon Nov 21, 2023
You're on an Apple Silicon Mac and you're cloning and go running inside an amd64 container?
zerok commentedon Nov 21, 2023
Exactly 🙂
10 remaining items
AdrienPoupa commentedon Nov 21, 2023
I built a 8.2 image, and it works fine:
It seems 8.1 is broken, but that means we can't use the new option with our existing image, even with the latest PHP 8.1 stable version - meaning I feel the activation by default was a bit rushed.
dgageot commentedon Nov 21, 2023
@zerok a fix to your workflow should ship in Docker Desktop 4.26.0. We could reproduce it on 4.25.1 but not on our main branch where we added many fixes to Rosetta.
@AdrienPoupa no fix for php < 8.1 yet. I'm still working on it and will keep you posted!
dgageot commentedon Nov 21, 2023
@AdrienPoupa FWIW, I also couldn't reproduce the issue with
php:8.1.25-alpineimageAdrienPoupa commentedon Nov 21, 2023
Same here, php:8.1-fpm works fine so it is either coming from the different Ubuntu base, or one of the extensions
dgageot commentedon Nov 24, 2023
@AdrienPoupa it's coming from OPCache and the way it's using
mmap. It has been fixed in php 8.2.You can also try 8.1 with this option in
opcache.ini:opcache.preferred_memory_model=shmthaJeztah commentedon Nov 25, 2023
Looks like a fix / improvement was made in Docker Desktop, which will ship with the next release
dgageot commentedon Dec 6, 2023
@AdrienPoupa did you get a chance to test Docker Desktop v4.26.0?
AdrienPoupa commentedon Dec 6, 2023
I just did, looks like it is fixed, thank you very much!
dgageot commentedon Dec 6, 2023
I'm going to close this issue. Feel free to reopen
zerok commentedon Dec 6, 2023
Thank you 😊 my case also works with 4.26 🥳
fix(rosetta): supply AT_BASE so musl-dynamic x86_64 binaries run
fix(rosetta): supply AT_BASE so musl-dynamic x86_64 binaries run