Skip to content

Commit

Permalink
Rollup merge of rust-lang#112708 - flip1995:clippy-freezing-pc-with-i…
Browse files Browse the repository at this point in the history
…ce, r=cjgillot

Revert "Don't hold the active queries lock while calling `make_query`"

This reverts commit fd3d2d4.

This has the side effect, that when Clippy should ICE (during an EarlyPass?) it will fill up the RAM with 2 GB/s and then freezes the PC. I don't know the correct solution, but this is blocking the Clippy sync and might give some people really bad experiences, so this should be reverted ASAP.

Reverts rust-lang#112333

r? `@cjgillot`
cc `@Zoxc`

I only commented this on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.60try_print_query_stack.60.20has.20.60ImplicitCtx.60.20during.20.60EarlyPass.60/near/363926180). I should've left a comment on the PR as well. My bad.
  • Loading branch information
GuillaumeGomez authored Jun 22, 2023
2 parents fa06a37 + 68ecff3 commit d3312a9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
15 changes: 4 additions & 11 deletions compiler/rustc_query_system/src/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ 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
Expand All @@ -79,7 +77,8 @@ where
for shard in shards.iter() {
for (k, v) in shard.iter() {
if let QueryResult::Started(ref job) = *v {
active.push((*k, job.clone()));
let query = make_query(qcx, *k);
jobs.insert(job.id, QueryJobInfo { query, job: job.clone() });
}
}
}
Expand All @@ -92,18 +91,12 @@ where
// really hurt much.)
for (k, v) in self.active.try_lock()?.iter() {
if let QueryResult::Started(ref job) = *v {
active.push((*k, job.clone()));
let query = make_query(qcx, *k);
jobs.insert(job.id, QueryJobInfo { query, job: 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(())
}
}
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/treat-err-as-bug/panic-causes-oom-112708.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// compile-flags: -Ztreat-err-as-bug
// dont-check-failure-status
// error-pattern: aborting due to `-Z treat-err-as-bug=1`
// normalize-stderr-test "note: .*\n\n" -> ""
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
// rustc-env:RUST_BACKTRACE=0

fn main() {
#[deny(while_true)]
while true {}
}
16 changes: 16 additions & 0 deletions tests/ui/treat-err-as-bug/panic-causes-oom-112708.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error: denote infinite loops with `loop { ... }`
--> $DIR/panic-causes-oom-112708.rs:10:5
|
LL | while true {}
| ^^^^^^^^^^ help: use `loop`
|
note: the lint level is defined here
--> $DIR/panic-causes-oom-112708.rs:9:12
|
LL | #[deny(while_true)]
| ^^^^^^^^^^

error: the compiler unexpectedly panicked. this is a bug.

query stack during panic:
thread panicked while processing panic. aborting.

0 comments on commit d3312a9

Please sign in to comment.