-
Notifications
You must be signed in to change notification settings - Fork 13.3k
-Zthreads causes rustfix/jobserver to deadlock #133873
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
Labels
A-parallel-compiler
Area: parallel compiler
C-bug
Category: This is a bug.
I-hang
Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Apr 22, 2025
Add a jobserver proxy to ensure at least one token is always held This adds a jobserver proxy to ensure at least one token is always held by `rustc`. Currently with `-Z threads` `rustc` can temporarily give up all its tokens, causing `cargo` to spawn additional `rustc` instances beyond the job limit. The current behavior causes an issue with `cargo fix` which has a global lock preventing concurrent `rustc` instances, but it also holds a jobserver token, causing a deadlock when `rustc` gives up its token. That is fixed by this PR. Fixes rust-lang#133873 and rust-lang#140093.
lnicola
pushed a commit
to lnicola/rust-analyzer
that referenced
this issue
May 1, 2025
Add a jobserver proxy to ensure at least one token is always held This adds a jobserver proxy to ensure at least one token is always held by `rustc`. Currently with `-Z threads` `rustc` can temporarily give up all its tokens, causing `cargo` to spawn additional `rustc` instances beyond the job limit. The current behavior causes an issue with `cargo fix` which has a global lock preventing concurrent `rustc` instances, but it also holds a jobserver token, causing a deadlock when `rustc` gives up its token. That is fixed by this PR. Fixes rust-lang/rust#67385. Fixes rust-lang/rust#133873. Fixes rust-lang/rust#140093.
github-actions bot
pushed a commit
to rust-lang/miri
that referenced
this issue
May 3, 2025
Add a jobserver proxy to ensure at least one token is always held This adds a jobserver proxy to ensure at least one token is always held by `rustc`. Currently with `-Z threads` `rustc` can temporarily give up all its tokens, causing `cargo` to spawn additional `rustc` instances beyond the job limit. The current behavior causes an issue with `cargo fix` which has a global lock preventing concurrent `rustc` instances, but it also holds a jobserver token, causing a deadlock when `rustc` gives up its token. That is fixed by this PR. Fixes rust-lang/rust#67385. Fixes rust-lang/rust#133873. Fixes rust-lang/rust#140093.
github-actions bot
pushed a commit
to rust-lang/rustc-dev-guide
that referenced
this issue
May 5, 2025
Add a jobserver proxy to ensure at least one token is always held This adds a jobserver proxy to ensure at least one token is always held by `rustc`. Currently with `-Z threads` `rustc` can temporarily give up all its tokens, causing `cargo` to spawn additional `rustc` instances beyond the job limit. The current behavior causes an issue with `cargo fix` which has a global lock preventing concurrent `rustc` instances, but it also holds a jobserver token, causing a deadlock when `rustc` gives up its token. That is fixed by this PR. Fixes rust-lang/rust#67385. Fixes rust-lang/rust#133873. Fixes rust-lang/rust#140093.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-parallel-compiler
Area: parallel compiler
C-bug
Category: This is a bug.
I-hang
Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
git clone --recursive -b rustfix_deadlock_repro https://gitlab.com/lib.rs/main.git/ cd main cargo +nightly fix --edition-idioms --all --allow-dirty cargo +nightly fix --edition-idioms --all --allow-dirty
The config in
.cargo/config.toml
has-Zthreads=10
. I'm running it on 16-core Apple M3 Max. I can also reproduce the deadlock with-Zthreads=2
. It doesn't deadlock without-Zthreads
.The deadlock happens reliably when running
cargo fix
. It doesn't happen when runningcargo test
orcargo check
.Cargo is waiting in
rustfix_crate
on a TCP read, waiting forrustc
to give signs of life. It can get stuck with even a singlerustc
process running.Rustc process is stuck here:
Backtrace from another run when there was only a single
rustc
process spawned:The text was updated successfully, but these errors were encountered: