-
Notifications
You must be signed in to change notification settings - Fork 121
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
Rosetta emulation mishandles /proc/<pid>/cmdline in 4.25.0 #7058
Comments
Hello @gwynne, unfortunately, this is not something that can be fixed. With Rosetta enabled, you'll see something like:
With Qemu, it'll be:
It's actually a feature of the Linux Kernel to preserve this |
@dgageot As it happens, I agree with regards to the Swift compiler (and as you can see in the issue I filed against it, I've made that argument to them). But the behavior of Rosetta versus Qemu changed between 4.24.2 and 4.25.0; Rosetta exhibits the problem in 4.25.0, Qemu does not. Neither does in 4.24.2. |
(The issue still exists in 4.25.1 as well) |
Yes, it's in 4.25.1 and it'll stay this way in the forceable future. Very sorry for you. |
This issue can be fixed by following steps, which will remain in effect until you exit Docker Desktop. $ docker run -it --rm --platform=linux/amd64 ubuntu cat /proc/self/cmdline|xargs -0 echo
/usr/bin/cat cat /proc/self/cmdline
$ docker run -it --rm --privileged --pid=host justincormack/nsenter1
~ # mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
~ # echo -1 >/proc/sys/fs/binfmt_misc/rosetta
~ # echo ':rosetta:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00:\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/run/rosetta/rosetta:OCF' >/proc/sys/fs
/binfmt_misc/register
~ # exit
$ docker run -it --rm --platform=linux/amd64 ubuntu cat /proc/self/cmdline|xargs -0 echo
/usr/bin/cat /proc/self/cmdline |
I have created re-register-rosetta that performs this fix. docker run --rm --privileged ghcr.io/norio-nomura/re-register-rosetta example: $ docker run --rm --platform=linux/amd64 ubuntu cat /proc/self/cmdline|xargs -0 echo
/usr/bin/cat cat /proc/self/cmdline
$ docker run --rm --privileged ghcr.io/norio-nomura/re-register-rosetta
Rosetta is not correctly registered. Re-registering rosetta...
Successfully re-registered Rosetta.
$ docker run --rm ghcr.io/norio-nomura/re-register-rosetta
It looks like Rosetta is correctly registered.
$ docker run --rm --platform=linux/amd64 ubuntu cat /proc/self/cmdline|xargs -0 echo
cat /proc/self/cmdline |
I assume the root cause of this issue is that Docker Desktop for Mac specifies
The way I was modifying my earlier post is just to re-register without specifying this My fix reverts back to before the fix when Docker Desktop for Mac enters Resource Saver Mode. |
I don't think this is really a Docker bug. Either we (Swift) shouldn't be using |
Hmmm. Looking into this a bit further, with every combination I've tried except Rosetta, reading
This makes me think that whatever |
I guess the |
Yeah, I've wondered if the problem was at least partially Rosetta's fault. (I also never got a chance to check whether the issue shows up in Ventura or only in Sonoma...) |
That's certainly interesting. I'll have to investigate this a bit further at my end. |
I used that information to create a tool in #7058 (comment) to re-register with |
Indeed. I'm asking the Rosetta folks here about it, because — depending on what they say — I might change my mind about this being a bug in Docker Desktop. Though it would probably be better if Rosetta supported |
Update: this isn't a bug in Swift or Docker Desktop. Apparently, reading |
I have come the same conclusion that There's no way to see the status of |
There is not, sorry. In the case of Swift, we changed to not using Swift 5.10 has the fix, if you're a Swift user reading this. |
🤯 Holy molly. That's one terrible piece of code. I'm gonna go wash my eyes with bleach now to try to unsee that. |
🤣 To be fair, it is really only relying on the Linux ABI (which is well defined) and the fact that |
Description
After updating to Docker Desktop for Mac 4.25.0, Ubuntu 22.04 images running under Rosetta 2 emulation began to show corrupted
/proc/<pid>/cmdline
contents. Specifically, the actual contents ofargv[0]
are appended as an argument following the full executable path which previously representedargv[0]
. Intermittently,/rosetta/rosetta
is additionally prepended. This wreaks havoc with processes (such as Apple's Swift compiler toolchain) which rely on the contents of/proc/self/cmdline
for convenient access toargc
andargv
. The actualargc
andargv
values passed tomain()
are unchanged.Reproduce
docker run -ti --pull always --platform=linux/amd64 ubuntu:latest
ps -axjww
cat /proc/1/cmdline | xargs -0 echo
Expected behavior
The output of both commands should closely match the results when running Docker Desktop 4.24.2:
docker version
Client: Cloud integration: v1.0.35+desktop.5 Version: 24.0.6 API version: 1.43 Go version: go1.20.7 Git commit: ed223bc Built: Mon Sep 4 12:28:49 2023 OS/Arch: darwin/arm64 Context: desktop-linux Server: Docker Desktop 4.25.0 (126437) Engine: Version: 24.0.6 API version: 1.43 (minimum version 1.12) Go version: go1.20.7 Git commit: 1a79695 Built: Mon Sep 4 12:31:36 2023 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.6.22 GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca runc: Version: 1.1.8 GitCommit: v1.1.8-0-g82f18fe docker-init: Version: 0.19.0 GitCommit: de40ad0
docker info
Diagnostics ID
CEC81793-5002-4A5E-9D37-5B165C9B772A/20231104060157
Additional Info
No response
The text was updated successfully, but these errors were encountered: