diff options
| author | Felix Rath <felixm.rath@gmail.com> | 2024-08-12 03:16:39 +0200 |
|---|---|---|
| committer | Felix Rath <felixm.rath@gmail.com> | 2024-08-19 17:42:42 +0200 |
| commit | 2bf24559252f9e4a186ea6227827c0c7c417471a (patch) | |
| tree | 37205a4907696f338a936d91fbc9f6e41f6bcf56 /compiler/rustc_query_system | |
| parent | e3f909b2bbd0b10db6f164d466db237c582d3045 (diff) | |
| download | rust-2bf24559252f9e4a186ea6227827c0c7c417471a.tar.gz rust-2bf24559252f9e4a186ea6227827c0c7c417471a.zip | |
Prevent double panic in query system, improve diagnostics
Diffstat (limited to 'compiler/rustc_query_system')
| -rw-r--r-- | compiler/rustc_query_system/src/query/plumbing.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 8ef680cdb6c..6dbd6e89fe9 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -181,8 +181,15 @@ where cache.complete(key, result, dep_node_index); let job = { - let mut lock = state.active.lock_shard_by_value(&key); - lock.remove(&key).unwrap().expect_job() + let val = { + // don't keep the lock during the `unwrap()` of the retrieved value, or we taint the + // underlying shard. + // since unwinding also wants to look at this map, this can also prevent a double + // panic. + let mut lock = state.active.lock_shard_by_value(&key); + lock.remove(&key) + }; + val.unwrap().expect_job() }; job.signal_complete(); |
