Skip to content

Commit e9aa0e7

Browse files
committed
Use existing Handler to print query stack
When the panic handler is run, the existing Handler may be in a weird state if it was responsible for triggering the panic. By using a freshly created Handler, we avoid trying to re-entrantly lock a HandlerInner, which was causing a double panic on ICEs.
1 parent ddf4386 commit e9aa0e7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/librustc/ty/query/plumbing.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use errors::DiagnosticBuilder;
1515
use errors::Level;
1616
use errors::Diagnostic;
1717
use errors::FatalError;
18+
use errors::Handler;
1819
use rustc_data_structures::fx::{FxHashMap};
1920
use rustc_data_structures::sync::{Lrc, Lock};
2021
use rustc_data_structures::sharded::Sharded;
@@ -321,7 +322,7 @@ impl<'tcx> TyCtxt<'tcx> {
321322
})
322323
}
323324

324-
pub fn try_print_query_stack() {
325+
pub fn try_print_query_stack(handler: &Handler) {
325326
eprintln!("query stack during panic:");
326327

327328
tls::with_context_opt(|icx| {
@@ -336,7 +337,7 @@ impl<'tcx> TyCtxt<'tcx> {
336337
query.info.query.name(),
337338
query.info.query.describe(icx.tcx)));
338339
diag.span = icx.tcx.sess.source_map().def_span(query.info.span).into();
339-
icx.tcx.sess.diagnostic().force_print_diagnostic(diag);
340+
handler.force_print_diagnostic(diag);
340341

341342
current_query = query.parent.clone();
342343
i += 1;

src/librustc_driver/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
12311231
let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false);
12321232

12331233
if backtrace {
1234-
TyCtxt::try_print_query_stack();
1234+
TyCtxt::try_print_query_stack(&handler);
12351235
}
12361236

12371237
#[cfg(windows)]

0 commit comments

Comments
 (0)