mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Rollup merge of #112333 - Zoxc:try_collect_active_jobs-deadlock, r=cjgillot
Don't hold the active queries lock while calling `make_query` This moves the call to `make_query` outside the parts that holds the active queries lock in `try_collect_active_jobs`. This should help removed the deadlock and borrow panic that has been observed when printing the query stack during an ICE. cc `@SparrowLii` r? `@cjgillot`
This commit is contained in:
commit
4f2e1df29d
@ -69,6 +69,8 @@ where
|
||||
make_query: fn(Qcx, K) -> QueryStackFrame<D>,
|
||||
jobs: &mut QueryMap<D>,
|
||||
) -> Option<()> {
|
||||
let mut active = Vec::new();
|
||||
|
||||
#[cfg(parallel_compiler)]
|
||||
{
|
||||
// We use try_lock_shards here since we are called from the
|
||||
@ -77,8 +79,7 @@ where
|
||||
for shard in shards.iter() {
|
||||
for (k, v) in shard.iter() {
|
||||
if let QueryResult::Started(ref job) = *v {
|
||||
let query = make_query(qcx, *k);
|
||||
jobs.insert(job.id, QueryJobInfo { query, job: job.clone() });
|
||||
active.push((*k, job.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,12 +92,18 @@ where
|
||||
// really hurt much.)
|
||||
for (k, v) in self.active.try_lock()?.iter() {
|
||||
if let QueryResult::Started(ref job) = *v {
|
||||
let query = make_query(qcx, *k);
|
||||
jobs.insert(job.id, QueryJobInfo { query, job: job.clone() });
|
||||
active.push((*k, job.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Call `make_query` while we're not holding a `self.active` lock as `make_query` may call
|
||||
// queries leading to a deadlock.
|
||||
for (key, job) in active {
|
||||
let query = make_query(qcx, key);
|
||||
jobs.insert(job.id, QueryJobInfo { query, job });
|
||||
}
|
||||
|
||||
Some(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user