Skip to content

Make Proxy weak reference as it seems that it is not dropped at all - #165676

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
aerooneqq:make-proxy-weak-reference-in-helper-thread
Nov 9, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
aerooneqq:make-proxy-weak-reference-in-helper-thread

Conversation

@aerooneqq

@aerooneqq aerooneqq commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Split from #165506 which makes Proxy droppable, which locally fixes the issue:

thread 'jobserver::jobserver_and_j' (126990) panicked at src/tools/cargo/tests/testsuite/jobserver.rs:411:10:

---- expected: tests/testsuite/jobserver.rs:405:27
++++ actual:   stderr
   1    1 | [WARNING] a `-j` argument was passed to Cargo but Cargo is also configured with an external jobserver in its environment, ignoring the `-j` parameter
   2    2 | [COMPILING] foo v0.0.1 ([ROOT]/foo)
   3    3 | [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
        4 + make[1]: INTERNAL: Exiting with 1 jobserver tokens available; should be 2!

(see #162848 (comment)).

r? @petrochenkov

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 9, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5ea937e has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 9, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 9, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #165161 (`rustc_builtin_macros` cleanup, part 9)
 - #165663 (Avoid repeated gated spans snapshots during macro matching)
 - #165637 (library: std: process: Make Command::status platform specific)
 - #163571 ([rustdoc] Render `Deref` methods on aliased items)
 - #164712 (Reject unexpanded attributes in attributes)
 - #165516 (Point at array length instead of whole array type)
 - #165674 (Add regression test for issue 118449)
 - #165676 (Make `Proxy` weak reference as it seems that it is not dropped at all)
 - #165695 (Add regression test for unsafe diagnostic attributes)
@rust-bors
rust-bors Bot merged commit 020840d into rust-lang:main Nov 9, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 9, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 9, 2026
Rollup merge of #165676 - aerooneqq:make-proxy-weak-reference-in-helper-thread, r=petrochenkov

Make `Proxy` weak reference as it seems that it is not dropped at all

Split from #165506 which makes `Proxy` droppable, which locally fixes the issue:
```rust
thread 'jobserver::jobserver_and_j' (126990) panicked at src/tools/cargo/tests/testsuite/jobserver.rs:411:10:

---- expected: tests/testsuite/jobserver.rs:405:27
++++ actual:   stderr
   1    1 | [WARNING] a `-j` argument was passed to Cargo but Cargo is also configured with an external jobserver in its environment, ignoring the `-j` parameter
   2    2 | [COMPILING] foo v0.0.1 ([ROOT]/foo)
   3    3 | [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
        4 + make[1]: INTERNAL: Exiting with 1 jobserver tokens available; should be 2!
```

(see #162848 (comment)).

r? @petrochenkov
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 12, 2026
…hread, r=petrochenkov

Explicitly drop job server helper thread

An adaptation of an LLM patch that was generated in https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/Interaction.20of.20Cargo.20jobserver.20tests.20and.20parallel.20frontend/with/639482582.

The original patch consisted from two fixes: explicit drop of a helper thread and additional logic for job server token request counting. This PR implements only the explicit drop part as I don't see how additional requests counting logic should help the issue.

This reworks rust-lang#165676, as the [rationale](https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/Interaction.20of.20Cargo.20jobserver.20tests.20and.20parallel.20frontend/near/639152114) behind explicit drop of a helper thread seems reasonable for me:

> From my rough understanding, while helper is handling a token, its upgrade() is often the last strong ref I guess. So, when run_in_thread_pool_with_globals returns and rustc exits, the token may still be in helper's hands.

This fix didn't fail after several launches in rust-lang#165506 and locally.

r? @petrochenkov
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 12, 2026
…hread, r=petrochenkov

Explicitly drop job server helper thread

An adaptation of an LLM patch that was generated in https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/Interaction.20of.20Cargo.20jobserver.20tests.20and.20parallel.20frontend/with/639482582.

The original patch consisted from two fixes: explicit drop of a helper thread and additional logic for job server token request counting. This PR implements only the explicit drop part as I don't see how additional requests counting logic should help the issue.

This reworks rust-lang#165676, as the [rationale](https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/Interaction.20of.20Cargo.20jobserver.20tests.20and.20parallel.20frontend/near/639152114) behind explicit drop of a helper thread seems reasonable for me:

> From my rough understanding, while helper is handling a token, its upgrade() is often the last strong ref I guess. So, when run_in_thread_pool_with_globals returns and rustc exits, the token may still be in helper's hands.

This fix didn't fail after several launches in rust-lang#165506 and locally.

r? @petrochenkov
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 12, 2026
…hread, r=petrochenkov

Explicitly drop job server helper thread

An adaptation of an LLM patch that was generated in https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/Interaction.20of.20Cargo.20jobserver.20tests.20and.20parallel.20frontend/with/639482582.

The original patch consisted from two fixes: explicit drop of a helper thread and additional logic for job server token request counting. This PR implements only the explicit drop part as I don't see how additional requests counting logic should help the issue.

This reworks rust-lang#165676, as the [rationale](https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/Interaction.20of.20Cargo.20jobserver.20tests.20and.20parallel.20frontend/near/639152114) behind explicit drop of a helper thread seems reasonable for me:

> From my rough understanding, while helper is handling a token, its upgrade() is often the last strong ref I guess. So, when run_in_thread_pool_with_globals returns and rustc exits, the token may still be in helper's hands.

This fix didn't fail after several launches in rust-lang#165506 and locally.

r? @petrochenkov
rust-bors Bot pushed a commit that referenced this pull request Nov 12, 2026
Rollup merge of #165854 - aerooneqq:explicitly-drop-helper-thread, r=petrochenkov

Explicitly drop job server helper thread

An adaptation of an LLM patch that was generated in https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/Interaction.20of.20Cargo.20jobserver.20tests.20and.20parallel.20frontend/with/639482582.

The original patch consisted from two fixes: explicit drop of a helper thread and additional logic for job server token request counting. This PR implements only the explicit drop part as I don't see how additional requests counting logic should help the issue.

This reworks #165676, as the [rationale](https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/Interaction.20of.20Cargo.20jobserver.20tests.20and.20parallel.20frontend/near/639152114) behind explicit drop of a helper thread seems reasonable for me:

> From my rough understanding, while helper is handling a token, its upgrade() is often the last strong ref I guess. So, when run_in_thread_pool_with_globals returns and rustc exits, the token may still be in helper's hands.

This fix didn't fail after several launches in #165506 and locally.

r? @petrochenkov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants