about summary refs log tree commit diff
path: root/compiler/rustc_interface/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-09 15:37:01 +0000
committerbors <bors@rust-lang.org>2024-03-09 15:37:01 +0000
commit8401645716b26a8b4c6974dc0680e55e81e9e8a1 (patch)
treeca23dab2f3839143d11760c3ce8db630cbc5a34a /compiler/rustc_interface/src
parentb054da815501bafb24a08284151d32862f7a3a13 (diff)
parent7193ce0061625647166281b1965cfa320e170eb7 (diff)
downloadrust-8401645716b26a8b4c6974dc0680e55e81e9e8a1.tar.gz
rust-8401645716b26a8b4c6974dc0680e55e81e9e8a1.zip
Auto merge of #122241 - matthiaskrgr:rollup-r8q87ok, r=matthiaskrgr
Rollup of 12 pull requests

Successful merges:

 - #121358 (Reduce alignment of TypeId to u64 alignment)
 - #121813 (Misc improvements to non local defs lint implementation)
 - #122160 (Eagerly translate `HelpUseLatestEdition` in parser diagnostics)
 - #122178 (ci: add a runner for vanilla LLVM 18)
 - #122187 (Move metadata header and version checks together)
 - #122209 (fix incorrect path resolution in tidy)
 - #122215 (Some tweaks to the parallel query cycle handler)
 - #122223 (Fix typo in `VisitorResult`)
 - #122224 (Add missing regression tests)
 - #122232 (library/core: fix a comment, and a cfg(miri) warning)
 - #122233 (miri: do not apply aliasing restrictions to Box with custom allocator)
 - #122237 (Remove `Ord` from `ClosureKind`)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_interface/src')
-rw-r--r--compiler/rustc_interface/src/util.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs
index 0d50200133c..23bd2dac57e 100644
--- a/compiler/rustc_interface/src/util.rs
+++ b/compiler/rustc_interface/src/util.rs
@@ -101,10 +101,11 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
     threads: usize,
     f: F,
 ) -> R {
-    use rustc_data_structures::{jobserver, sync::FromDyn};
+    use rustc_data_structures::{defer, jobserver, sync::FromDyn};
     use rustc_middle::ty::tls;
     use rustc_query_impl::QueryCtxt;
-    use rustc_query_system::query::{deadlock, QueryContext};
+    use rustc_query_system::query::{break_query_cycles, QueryContext};
+    use std::process;
 
     let registry = sync::Registry::new(std::num::NonZero::new(threads).unwrap());
 
@@ -128,7 +129,19 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
             let query_map =
                 FromDyn::from(tls::with(|tcx| QueryCtxt::new(tcx).collect_active_jobs()));
             let registry = rayon_core::Registry::current();
-            thread::spawn(move || deadlock(query_map.into_inner(), &registry));
+            thread::Builder::new()
+                .name("rustc query cycle handler".to_string())
+                .spawn(move || {
+                    let on_panic = defer(|| {
+                        eprintln!("query cycle handler thread panicked, aborting process");
+                        // We need to abort here as we failed to resolve the deadlock,
+                        // otherwise the compiler could just hang,
+                        process::abort();
+                    });
+                    break_query_cycles(query_map.into_inner(), &registry);
+                    on_panic.disable();
+                })
+                .unwrap();
         });
     if let Some(size) = get_stack_size() {
         builder = builder.stack_size(size);