Sorry for the cryptic title, didn't knew exactly what to put there. On musl targets (well x86_64-unknown-linux-musl and arm-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:
[pid 11648] pipe( <unfinished ...>
[pid 11647] ioctl(9, FIOCLEX <unfinished ...>
[pid 11648] <... pipe resumed> [11, 12]) = 0
[pid 11647] <... ioctl resumed> ) = 0
[pid 11648] ioctl(11, FIOCLEX <unfinished ...>
[pid 11647] ioctl(10, FIOCLEX <unfinished ...>
vs the x86_64-unknown-linux-gnu target:
[pid 2128] pipe2( <unfinished ...>
[pid 2127] pipe2( <unfinished ...>
[pid 2128] <... pipe2 resumed> [6, 7], O_CLOEXEC) = 0
[pid 2127] <... pipe2 resumed> [8, 9], O_CLOEXEC) = 0
Versions affected:
- 1.30.1
- 1.31.0 - Current stable
- rustc 1.32.0-nightly (4a45578 2018-12-07)
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).
Sorry for the cryptic title, didn't knew exactly what to put there. On musl targets (well
x86_64-unknown-linux-muslandarm-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-gnutarget: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).