about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-08-26 14:15:14 +0000
committerbors <bors@rust-lang.org>2023-08-26 14:15:14 +0000
commit22d41ae90facbffdef9115809e8b6c1f71ebbf7c (patch)
tree91568370780ccfc633f885acb4f7e28fa2d4f74b
parent7646ece98831027694ffcc89cff514ee5da77c4e (diff)
parent3040d92dc46e6074fcc15bc2b8ed0516e81d573c (diff)
downloadrust-22d41ae90facbffdef9115809e8b6c1f71ebbf7c.tar.gz
rust-22d41ae90facbffdef9115809e8b6c1f71ebbf7c.zip
Auto merge of #115198 - Zoxc:query-panic-wait, r=cjgillot
Fix waiting on a query that panicked

This fixes waiting on a query that panicked. The code now looks for `QueryResult::Poisoned` in the query state in addition to the query cache. This fixes https://github.com/rust-lang/rust/issues/111528.

r? `@cjgillot`
-rw-r--r--compiler/rustc_query_system/src/query/plumbing.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs
index 4adb4eb7475..575921b3337 100644
--- a/compiler/rustc_query_system/src/query/plumbing.rs
+++ b/compiler/rustc_query_system/src/query/plumbing.rs
@@ -300,7 +300,18 @@ where
     match result {
         Ok(()) => {
             let Some((v, index)) = query.query_cache(qcx).lookup(&key) else {
-                cold_path(|| panic!("value must be in cache after waiting"))
+                cold_path(|| {
+                    // We didn't find the query result in the query cache. Check if it was
+                    // poisoned due to a panic instead.
+                    let lock = query.query_state(qcx).active.get_shard_by_value(&key).lock();
+                    match lock.get(&key) {
+                        // The query we waited on panicked. Continue unwinding here.
+                        Some(QueryResult::Poisoned) => FatalError.raise(),
+                        _ => panic!(
+                            "query result must in the cache or the query must be poisoned after a wait"
+                        ),
+                    }
+                })
             };
 
             qcx.dep_context().profiler().query_cache_hit(index.into());