Skip to content

Commit 11de037

Browse files
authored
Unrolled build for rust-lang#118169
Rollup merge of rust-lang#118169 - SparrowLii:deadlock_issue, r=compiler-errors print query map for deadlock when using parallel front end print query map for deadlock when using parallel front end, so that we can analyze where and why deadlock occurs
2 parents 1934665 + c238e87 commit 11de037

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

compiler/rustc_query_system/src/query/job.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub struct QueryInfo {
3838
pub type QueryMap = FxHashMap<QueryJobId, QueryJobInfo>;
3939

4040
/// A value uniquely identifying an active query job.
41-
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
41+
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
4242
pub struct QueryJobId(pub NonZeroU64);
4343

4444
impl QueryJobId {
@@ -62,14 +62,14 @@ impl QueryJobId {
6262
}
6363
}
6464

65-
#[derive(Clone)]
65+
#[derive(Clone, Debug)]
6666
pub struct QueryJobInfo {
6767
pub query: QueryStackFrame,
6868
pub job: QueryJob,
6969
}
7070

7171
/// Represents an active query job.
72-
#[derive(Clone)]
72+
#[derive(Clone, Debug)]
7373
pub struct QueryJob {
7474
pub id: QueryJobId,
7575

@@ -182,6 +182,7 @@ impl QueryJobId {
182182
}
183183

184184
#[cfg(parallel_compiler)]
185+
#[derive(Debug)]
185186
struct QueryWaiter {
186187
query: Option<QueryJobId>,
187188
condvar: Condvar,
@@ -198,13 +199,14 @@ impl QueryWaiter {
198199
}
199200

200201
#[cfg(parallel_compiler)]
202+
#[derive(Debug)]
201203
struct QueryLatchInfo {
202204
complete: bool,
203205
waiters: Vec<Arc<QueryWaiter>>,
204206
}
205207

206208
#[cfg(parallel_compiler)]
207-
#[derive(Clone)]
209+
#[derive(Clone, Debug)]
208210
pub(super) struct QueryLatch {
209211
info: Arc<Mutex<QueryLatchInfo>>,
210212
}
@@ -540,7 +542,11 @@ pub fn deadlock(query_map: QueryMap, registry: &rayon_core::Registry) {
540542
// X to Y due to Rayon waiting and a true dependency from Y to X. The algorithm here
541543
// only considers the true dependency and won't detect a cycle.
542544
if !found_cycle {
543-
panic!("deadlock detected");
545+
if query_map.len() == 0 {
546+
panic!("deadlock detected without any query!")
547+
} else {
548+
panic!("deadlock detected! current query map:\n{:#?}", query_map);
549+
}
544550
}
545551

546552
// FIXME: Ensure this won't cause a deadlock before we return

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ where
203203
}
204204
}
205205

206-
#[derive(Clone)]
206+
#[derive(Clone, Debug)]
207207
pub(crate) struct CycleError {
208208
/// The query and related span that uses the cycle.
209209
pub usage: Option<(Span, QueryStackFrame)>,

0 commit comments

Comments
 (0)