Skip to content

Commit 5660f7f

Browse files
authored
Rollup merge of rust-lang#157351 - xmakro:fix/parallel-collect-jobs-warn, r=petrochenkov
Avoid leaking the query-job collection warning into the panic query stack Part of rust-lang#154314. When the compiler panics it prints the active query stack. That collection runs with `CollectActiveJobsKind::PartialAllowed`, which deliberately skips any query state shard whose lock it cannot take without waiting, since a complete job map is not needed just to print a stack. Under the parallel front-end another thread can still hold a shard lock while the panic is being reported, so a shard is skipped nondeterministically and a `warn!("Failed to collect active jobs ...")` was printed. Because warnings are shown by default (the default `RUSTC_LOG` filter is `WARN`), this leaked an extra line into the diagnostics of panicking compilations and made their output differ run to run. The panicking thread's own query chain is always collectible (a query does not hold its shard lock while it runs), so the printed stack itself is unaffected; only the spurious warning varied. A skipped shard is expected and tolerated on this path, so `warn!` was the wrong level for it to begin with. This lowers the message to `debug!` so it stays available with `RUSTC_LOG` but no longer pollutes the default output, and re-enables the one ui test that was disabled because of it.
2 parents c832971 + b6a2d84 commit 5660f7f

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

compiler/rustc_query_impl/src/execution.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_middle::query::{
1414
use rustc_middle::ty::TyCtxt;
1515
use rustc_middle::verify_ich::incremental_verify_ich;
1616
use rustc_span::{DUMMY_SP, Span};
17-
use tracing::warn;
17+
use tracing::debug;
1818

1919
use crate::dep_graph::{DepNode, DepNodeIndex};
2020
use crate::handle_cycle_error;
@@ -100,7 +100,12 @@ fn collect_active_query_jobs_inner<'tcx, C>(
100100
for shard in query.state.active.try_lock_shards() {
101101
match shard {
102102
Some(shard) => collect_shard_jobs(&shard),
103-
None => warn!("Failed to collect active jobs for query `{}`!", query.name),
103+
// This collection is best-effort (it is only used to print the query
104+
// stack on panic), so a contended shard is expected and fine to skip.
105+
// Emitting this at `warn!` would leak nondeterministically into the
106+
// panic output under the parallel front-end, where another thread may
107+
// still hold a shard lock, so keep it at `debug!`.
108+
None => debug!("Failed to collect active jobs for query `{}`!", query.name),
104109
}
105110
}
106111
}

tests/ui/resolve/proc_macro_generated_packed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! This test ICEs because the `repr(packed)` attribute
22
//! was generated by a proc macro, so `#[derive]` didn't see it.
3-
//@ ignore-parallel-frontend failed to collect active jobs
3+
44
//@proc-macro: proc_macro_generate_packed.rs
55
//@known-bug: #120873
66
//@ failure-status: 101

0 commit comments

Comments
 (0)