-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Musl pipe2 missing #56675
Comments
Did some investigation regarding this bug: More specifically the following comment: “It assumes that Well this is not the case for musl target binaries. pipe2 is one of the symbols rust uses this mechanism to check for existence.(for fair reasons, the symbol is not there on old kernels). But on any musl target this symbol does exist because musl is emulating it in it’s standard library in case the systemcall is missing. https://github.com/esmil/musl/blob/master/src/unistd/pipe2.c A solution would thus be to assume this symbol always exists on musl targets (and it’s probably the same for the other ones) and make the weak! macro return the symbol directly for such targets. I could do it myself if this sounds resonable. |
Thanks for the report @adrian-budau! Your investigation sounds right to me and I agree that we can probably just assume these symbols always exist on the musl target (as we're mostly pulling in the libc anyway). Should be fine to update the standard library to assume so! |
Is this kind of what you had in mind? master...adrian-budau:syscall_fix_musl I wanna know if I should go like this, or I understood you wrong. |
On musl targets assume certain symbols exist (like pipe2 and accept4). This fixes #56675. I don't know if this is the best solution, or if I should also add some tests so I'm waiting for some feedback. Thanks!
Sorry for the cryptic title, didn't knew exactly what to put there. On musl targets (well
x86_64-unknown-linux-musl
andarm-unknown-linux-musleabi
(hf)) for some reason pipe2 is not used (even on kernels that support it). Pipe2 is important to protect against race condition when multiple threads run external commands.The following is an example that due to this bug will deadlock on the musl targets listed above (and probably all linux musl ones).
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f004af72249cff12f048b4ba16fc4d6e
Running with strace proves that pipe2 is not used, and that instead the fallback is:
vs the
x86_64-unknown-linux-gnu
target:Versions affected:
Later Edit:
Just to be clear, if I compile a C file with the same musl toolchain that rust uses pipe2 works, so it's not a bug in Musl (or doesn't look like one to me).
The text was updated successfully, but these errors were encountered: