about summary refs log tree commit diff
path: root/compiler/rustc_query_system/src/query/plumbing.rs
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-03-25 18:09:05 +0100
committerGitHub <noreply@github.com>2025-03-25 18:09:05 +0100
commit43297ffc22ae4c053dc9904cd8a2cb0fde1198a9 (patch)
treee4c64433e9f14c4f5ca4141e6a018dbd343c9b63 /compiler/rustc_query_system/src/query/plumbing.rs
parent81e227583af709b43865b3069ba9e05dd595cff3 (diff)
parent34244c1477e4b485c51872fc3c6d846b4a3c6ffa (diff)
downloadrust-43297ffc22ae4c053dc9904cd8a2cb0fde1198a9.tar.gz
rust-43297ffc22ae4c053dc9904cd8a2cb0fde1198a9.zip
Rollup merge of #138581 - Zoxc:abort-handler-if-locked, r=SparrowLii
Abort in deadlock handler if we fail to get a query map

Resolving query cycles requires the complete active query map, or it may miss query cycles. We did not check that the map is completely constructed before. If there is some error collecting the map, something has gone wrong already. This adds a check to abort/panic if we fail to construct the complete map.

This can help differentiate errors from the `deadlock detected` case if constructing query map has errors in practice.

An `Option` is not used for `collect_active_jobs` as the panic handler can still make use of a partial map.
Diffstat (limited to 'compiler/rustc_query_system/src/query/plumbing.rs')
-rw-r--r--compiler/rustc_query_system/src/query/plumbing.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs
index d6b90fbc09f..3a9d80280c2 100644
--- a/compiler/rustc_query_system/src/query/plumbing.rs
+++ b/compiler/rustc_query_system/src/query/plumbing.rs
@@ -260,8 +260,11 @@ where
     Q: QueryConfig<Qcx>,
     Qcx: QueryContext,
 {
-    let error =
-        try_execute.find_cycle_in_stack(qcx.collect_active_jobs(), &qcx.current_query_job(), span);
+    // Ensure there was no errors collecting all active jobs.
+    // We need the complete map to ensure we find a cycle to break.
+    let query_map = qcx.collect_active_jobs().expect("failed to collect active queries");
+
+    let error = try_execute.find_cycle_in_stack(query_map, &qcx.current_query_job(), span);
     (mk_cycle(query, qcx, error), None)
 }