Repository: rust
Issue: deadlock detected
Labels: I-ICE,T-compiler,C-bug,WG-compiler-parallel

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-->

### Code
Was compiling Magisk, restarting the build didn't reproduce the deadlock.
Also happens sometimes in our CI.

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc version: 1.75.0-nightly (82e1608df 2023-12-21)
platform: x86_64-unknown-linux-gnu
```

### Error output

```
thread '<unnamed>' panicked at compiler/rustc_query_system/src/query/job.rs:543:9:
deadlock detected
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

```
stack backtrace:
   0:     0x72d08ff1d266 - std::backtrace::Backtrace::create::h0a6462f3eea549df
   1:     0x72d08ff1d1b0 - std::backtrace::Backtrace::force_capture::hb02aac8c888feca2
   2:     0x72d08db052c2 - <alloc[440799bb4e5b41a7]::boxed::Box<rustc_driver_impl[844ee308da7a7261]::install_ice_hook::{closure#0}> as core[2f5a2e599a74ee4]::ops::function::Fn<(&dyn for<'a, 'b> core[2f5a2e599a74ee4]::ops::function::Fn<(&'a core[2f5a2e599a74ee4]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[2f5a2e599a74ee4]::marker::Send + core[2f5a2e599a74ee4]::marker::Sync, &core[2f5a2e599a74ee4]::panic::panic_info::PanicInfo)>>::call
   3:     0x72d08ff17ced - std::panicking::rust_panic_with_hook::h4231f3e6cfdb46ff
   4:     0x72d08fed7219 - std::panicking::begin_panic_handler::{{closure}}::hd1e0f3424b548ff3
   5:     0x72d08fed6f76 - std::sys_common::backtrace::__rust_end_short_backtrace::h4c8ced2257dd83e4
   6:     0x72d08ff178b2 - rust_begin_unwind
   7:     0x72d08ff56155 - core::panicking::panic_fmt::h6060a9c486db388b
   8:     0x72d08f3b3179 - rustc_query_system[d49d4ca6edf10b08]::query::job::deadlock
   9:     0x72d08db04562 - std[83d40e3c662e7363]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[9ac7f1a2a0d2eeaa]::util::run_in_thread_pool_with_globals<rustc_interface[9ac7f1a2a0d2eeaa]::interface::run_compiler<(), rustc_driver_impl[844ee308da7a7261]::run_compiler::{closure#0}>::{closure#0}, ()>::{closure#2}::{closure#1}, ()>
  10:     0x72d08db1b11c - <<std[83d40e3c662e7363]::thread::Builder>::spawn_unchecked_<rustc_interface[9ac7f1a2a0d2eeaa]::util::run_in_thread_pool_with_globals<rustc_interface[9ac7f1a2a0d2eeaa]::interface::run_compiler<core[2f5a2e599a74ee4]::result::Result<(), rustc_span[df6e7a083c2dc1c1]::ErrorGuaranteed>, rustc_driver_impl[844ee308da7a7261]::run_compiler::{closure#1}>::{closure#0}, core[2f5a2e599a74ee4]::result::Result<(), rustc_span[df6e7a083c2dc1c1]::ErrorGuaranteed>>::{closure#2}::{closure#1}, ()>::{closure#1} as core[2f5a2e599a74ee4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  11:     0x72d08fec7625 - std::sys::unix::thread::Thread::new::thread_start::h0eaecf7f61de7e13
  12:     0x72d08ba6255a - <unknown>
  13:     0x72d08badfa3c - <unknown>
  14:                0x0 - <unknown>

```

</p>
</details>