Repository: rust
Issue: multi threads compile error: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



### 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 1.76.0-nightly (ba7c7a301 2023-11-13)
binary: rustc
commit-hash: ba7c7a301984967c8c13adb580ef9b86ba706a83
commit-date: 2023-11-13
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.4

```

### Error output

```
error: could not compile `tracing-core` (lib)

Caused by:
  process didn't exit successfully: `/home/zhichen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name tracing_core --edition=2018 /home/zhichen/.cargo/registry/src/rsproxy.cn-0dccff568467c15b/tracing-core-0.1.32/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=150 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="once_cell"' --cfg 'feature="std"' -C metadata=51aab342ecde7319 -C extra-filename=-51aab342ecde7319 --out-dir /home/zhichen/work/sca-scan/target/debug/deps -L dependency=/home/zhichen/work/sca-scan/target/debug/deps --extern once_cell=/home/zhichen/work/sca-scan/target/debug/deps/libonce_cell-fe848ebb2f78f957.rmeta --cap-lints allow -Z threads=20` (signal: 6, SIGABRT: process abort signal)
warning: build failed, waiting for other jobs to finish...
```

<!--
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>

```
thread '<unnamed>' panicked at compiler/rustc_query_system/src/query/job.rs:543:9:
deadlock detected
stack backtrace:
   0:     0x7fb88a173731 - std::backtrace_rs::backtrace::libunwind::trace::hde577349c76cce7f
                               at /rustc/ba7c7a301984967c8c13adb580ef9b86ba706a83/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fb88a173731 - std::backtrace_rs::backtrace::trace_unsynchronized::he8b81d0b329d8fa6
                               at /rustc/ba7c7a301984967c8c13adb580ef9b86ba706a83/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb88a173731 - std::backtrace::Backtrace::create::hedeb484d7c8418aa
                               at /rustc/ba7c7a301984967c8c13adb580ef9b86ba706a83/library/std/src/backtrace.rs:331:13
   3:     0x7fb88a173680 - std::backtrace::Backtrace::force_capture::hbd16e8a4afae6b37
                               at /rustc/ba7c7a301984967c8c13adb580ef9b86ba706a83/library/std/src/backtrace.rs:313:9
   4:     0x7fb88ceed18c - std[70c331c52e792e77]::panicking::update_hook::<alloc[ac42baf6c7d94bfa]::boxed::Box<rustc_driver_impl[662ed899c4750396]::install_ice_hook::{closure#0}>>::{closure#0}
   5:     0x7fb88a18e7d8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h01a2b076b44e44f8
                               at /rustc/ba7c7a301984967c8c13adb580ef9b86ba706a83/library/alloc/src/boxed.rs:2021:9
   6:     0x7fb88a18e7d8 - std::panicking::rust_panic_with_hook::h24b0c40fd36c8eee
                               at /rustc/ba7c7a301984967c8c13adb580ef9b86ba706a83/library/std/src/panicking.rs:783:13
   7:     0x7fb88a18e4f9 - std::panicking::begin_panic_handler::{{closure}}::hf0b52c49926ec9f4
                               at /rustc/ba7c7a301984967c8c13adb580ef9b86ba706a83/library/std/src/panicking.rs:649:13
   8:     0x7fb88a18bae6 - std::sys_common::backtrace::__rust_end_short_backtrace::h7112d64e85585c9d
                               at /rustc/ba7c7a301984967c8c13adb580ef9b86ba706a83/library/std/src/sys_common/backtrace.rs:170:18
   9:     0x7fb88a18e292 - rust_begin_unwind
                               at /rustc/ba7c7a301984967c8c13adb580ef9b86ba706a83/library/std/src/panicking.rs:645:5
  10:     0x7fb88a1dad05 - core::panicking::panic_fmt::h2c71ea7e0c1376d6
                               at /rustc/ba7c7a301984967c8c13adb580ef9b86ba706a83/library/core/src/panicking.rs:72:14
  11:     0x7fb88d7c4555 - rustc_query_system[16adaf3b80342c]::query::job::deadlock
  12:     0x7fb88cee86ec - std[70c331c52e792e77]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7bd5efb410cadaba]::util::run_in_thread_pool_with_globals<rustc_interface[7bd5efb410cadaba]::interface::run_compiler<core[4823536d104e8f97]::result::Result<(), rustc_span[43b04719702b35f]::ErrorGuaranteed>, rustc_driver_impl[662ed899c4750396]::run_compiler::{closure#1}>::{closure#0}, core[4823536d104e8f97]::result::Result<(), rustc_span[43b04719702b35f]::ErrorGuaranteed>>::{closure#2}::{closure#1}, ()>
  13:     0x7fb88ceef7a1 - <<std[70c331c52e792e77]::thread::Builder>::spawn_unchecked_<rustc_interface[7bd5efb410cadaba]::util::run_in_thread_pool_with_globals<rustc_interface[7bd5efb410cadaba]::interface::run_compiler<core[4823536d104e8f97]::result::Result<(), rustc_span[43b04719702b35f]::ErrorGuaranteed>, rustc_driver_impl[662ed899c4750396]::run_compiler::{closure#1}>::{closure#0}, core[4823536d104e8f97]::result::Result<(), rustc_span[43b04719702b35f]::ErrorGuaranteed>>::{closure#2}::{closure#1}, ()>::{closure#1} as core[4823536d104e8f97]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  14:     0x7fb88a198695 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hee7d8415653916ee
                               at /rustc/ba7c7a301984967c8c13adb580ef9b86ba706a83/library/alloc/src/boxed.rs:2007:9
  15:     0x7fb88a198695 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf8af5df67977eb57
                               at /rustc/ba7c7a301984967c8c13adb580ef9b86ba706a83/library/alloc/src/boxed.rs:2007:9
  16:     0x7fb88a198695 - std::sys::unix::thread::Thread::new::thread_start::hc878850cbd82a8f9
                               at /rustc/ba7c7a301984967c8c13adb580ef9b86ba706a83/library/std/src/sys/unix/thread.rs:108:17
  17:     0x7fb889f853ec - start_thread
                               at ./nptl/pthread_create.c:444:8
  18:     0x7fb88a005a4c - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  19:                0x0 - <unknown>


rustc version: 1.76.0-nightly (ba7c7a301 2023-11-13)
platform: x86_64-unknown-linux-gnu
```

</p>
</details>