mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Rollup merge of #129271 - futile:query-system/prevent-double-panic, r=michaelwoerister
Prevent double panic in query system, improve diagnostics I stumbled upon a double-panic in the query system while working on something else (#129102), which hid the real error cause for what I was debugging. This PR remedies that, so unwinding should be able to present more errors. It shouldn't really be relevant for code that doesn't ICE.
This commit is contained in:
commit
77303568c0
@ -702,11 +702,17 @@ macro_rules! define_queries {
|
||||
let name = stringify!($name);
|
||||
$crate::plumbing::create_query_frame(tcx, rustc_middle::query::descs::$name, key, kind, name)
|
||||
};
|
||||
tcx.query_system.states.$name.try_collect_active_jobs(
|
||||
let res = tcx.query_system.states.$name.try_collect_active_jobs(
|
||||
tcx,
|
||||
make_query,
|
||||
qmap,
|
||||
).unwrap();
|
||||
);
|
||||
// this can be called during unwinding, and the function has a `try_`-prefix, so
|
||||
// don't `unwrap()` here, just manually check for `None` and do best-effort error
|
||||
// reporting.
|
||||
if res.is_none() {
|
||||
tracing::warn!("Failed to collect active jobs for query with name `{}`!", stringify!($name));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn alloc_self_profile_query_strings<'tcx>(tcx: TyCtxt<'tcx>, string_cache: &mut QueryKeyStringCache) {
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user