Skip to content

Commit 22d41ae

Browse files
committed
Auto merge of rust-lang#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 rust-lang#111528. r? `@cjgillot`
2 parents 7646ece + 3040d92 commit 22d41ae

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compiler/rustc_query_system/src/query/plumbing.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,18 @@ where
300300
match result {
301301
Ok(()) => {
302302
let Some((v, index)) = query.query_cache(qcx).lookup(&key) else {
303-
cold_path(|| panic!("value must be in cache after waiting"))
303+
cold_path(|| {
304+
// We didn't find the query result in the query cache. Check if it was
305+
// poisoned due to a panic instead.
306+
let lock = query.query_state(qcx).active.get_shard_by_value(&key).lock();
307+
match lock.get(&key) {
308+
// The query we waited on panicked. Continue unwinding here.
309+
Some(QueryResult::Poisoned) => FatalError.raise(),
310+
_ => panic!(
311+
"query result must in the cache or the query must be poisoned after a wait"
312+
),
313+
}
314+
})
304315
};
305316

306317
qcx.dep_context().profiler().query_cache_hit(index.into());

0 commit comments

Comments
 (0)