-
Notifications
You must be signed in to change notification settings - Fork 95
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
Cross architecture support for dynamic linker (ld) #198
Comments
It works in ubuntu
|
First of all, I would strongly advise anyone that stumbles upon this issue to not use the linker to directly invoke any executable. This is not an intended use of the linker (it works only to support debug purposes), and is certainly not the "most tested path" if relied upon in production. Had invocation with the linker not been a factor, this entire issue would not exist. The linker does not load executables into memory the same way that the kernel does, and these subtle differences are what cause obscure issues like this to occur. This explains why shelling into the AL2 container works (this just executes As it turns out, this is a very specific issue that only manifests on operating systems where the user space is compiled to use The root cause of the SEGFAULT is that our QEMU user mode packages vend statically linked executables which are compiled with PIE (Position Independent Code) disabled. This can be seen in the output of the
Because of this, when the linker loads a program into memory via direct invocation, it overrides sections of the QEMU user mode executable. Because the QEMU user mode executable is basically an interpreter from a foreign architecture's machine code to native machine code, once the QEMU user mode binary is corrupted in memory, it causes the entire process to crash. There are a few workarounds to this (besides the obvious ones of "don't use AL2 / ET_EXEC user mode" and "don't directly invoke via the dynamic linker"):
In the unlikely scenario that someone else runs into this issue, please feel free to reopen it, but for now, I'm going to close this issue with the recommendation to use Rosetta 2 if possible. In the future, Finch may also install customized QEMU user mode binaries to mitigate this where Rosetta is not available (like on Intel macs, or when on Apple Silicon macs with macOS < 13.x). |
Describe the bug
Using dynamic linker (ld) to run commands will hang.
Steps to reproduce
Expected behavior
It should print "root" similar to running arm64 AL2 image.
Screenshots or logs
Added QEMU_STRACE=1 to print more logs.
Additional context
in M1 mac
The text was updated successfully, but these errors were encountered: