Skip to content

Commit 7987b17

Browse files
committed
remove deadlock detection
1 parent c360e21 commit 7987b17

File tree

7 files changed

+9
-379
lines changed

7 files changed

+9
-379
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4330,7 +4330,6 @@ version = "0.0.0"
43304330
dependencies = [
43314331
"hashbrown",
43324332
"parking_lot",
4333-
"rustc-rayon-core",
43344333
"rustc_abi",
43354334
"rustc_ast",
43364335
"rustc_attr_data_structures",

compiler/rustc_interface/src/util.rs

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_session::{EarlyDiagCtxt, Session, filesearch};
1919
use rustc_span::edit_distance::find_best_match_for_name;
2020
use rustc_span::edition::Edition;
2121
use rustc_span::source_map::SourceMapInputs;
22-
use rustc_span::{SessionGlobals, Symbol, sym};
22+
use rustc_span::{Symbol, sym};
2323
use rustc_target::spec::Target;
2424
use tracing::info;
2525

@@ -175,13 +175,7 @@ pub(crate) fn run_in_thread_pool_with_globals<
175175
sm_inputs: SourceMapInputs,
176176
f: F,
177177
) -> R {
178-
use std::process;
179-
180-
use rustc_data_structures::defer;
181178
use rustc_data_structures::sync::FromDyn;
182-
use rustc_middle::ty::tls;
183-
use rustc_query_impl::QueryCtxt;
184-
use rustc_query_system::query::{QueryContext, break_query_cycles};
185179

186180
let thread_stack_size = init_stack_size(thread_builder_diag);
187181

@@ -203,7 +197,6 @@ pub(crate) fn run_in_thread_pool_with_globals<
203197
}
204198

205199
let current_gcx = FromDyn::from(CurrentGcx::new());
206-
let current_gcx2 = current_gcx.clone();
207200

208201
let proxy = Proxy::new();
209202

@@ -214,46 +207,6 @@ pub(crate) fn run_in_thread_pool_with_globals<
214207
.acquire_thread_handler(move || proxy_.acquire_thread())
215208
.release_thread_handler(move || proxy__.release_thread())
216209
.num_threads(threads)
217-
.deadlock_handler(move || {
218-
// On deadlock, creates a new thread and forwards information in thread
219-
// locals to it. The new thread runs the deadlock handler.
220-
221-
let current_gcx2 = current_gcx2.clone();
222-
let registry = rayon_core::Registry::current();
223-
let session_globals = rustc_span::with_session_globals(|session_globals| {
224-
session_globals as *const SessionGlobals as usize
225-
});
226-
thread::Builder::new()
227-
.name("rustc query cycle handler".to_string())
228-
.spawn(move || {
229-
let on_panic = defer(|| {
230-
eprintln!("internal compiler error: query cycle handler thread panicked, aborting process");
231-
// We need to abort here as we failed to resolve the deadlock,
232-
// otherwise the compiler could just hang,
233-
process::abort();
234-
});
235-
236-
// Get a `GlobalCtxt` reference from `CurrentGcx` as we cannot rely on having a
237-
// `TyCtxt` TLS reference here.
238-
current_gcx2.access(|gcx| {
239-
tls::enter_context(&tls::ImplicitCtxt::new(gcx), || {
240-
tls::with(|tcx| {
241-
// Accessing session globals is sound as they outlive `GlobalCtxt`.
242-
// They are needed to hash query keys containing spans or symbols.
243-
let query_map = rustc_span::set_session_globals_then(unsafe { &*(session_globals as *const SessionGlobals) }, || {
244-
// Ensure there was no errors collecting all active jobs.
245-
// We need the complete map to ensure we find a cycle to break.
246-
QueryCtxt::new(tcx).collect_active_jobs().ok().expect("failed to collect active queries in deadlock handler")
247-
});
248-
break_query_cycles(query_map, &registry);
249-
})
250-
})
251-
});
252-
253-
on_panic.disable();
254-
})
255-
.unwrap();
256-
})
257210
.stack_size(thread_stack_size);
258211

259212
// We create the session globals on the main thread, then create the thread

compiler/rustc_query_system/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
parking_lot = "0.12"
9-
rustc-rayon-core = { version = "0.5.0" }
109
rustc_abi = { path = "../rustc_abi" }
1110
rustc_ast = { path = "../rustc_ast" }
1211
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }

0 commit comments

Comments
 (0)