Skip to content

Commit

Permalink
Auto merge of #115198 - Zoxc:query-panic-wait, r=cjgillot
Browse files Browse the repository at this point in the history
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 #111528.

r? `@cjgillot`
  • Loading branch information
bors committed Aug 26, 2023
2 parents 7646ece + 3040d92 commit 22d41ae
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion compiler/rustc_query_system/src/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 22d41ae

Please sign in to comment.