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.
This commit is contained in:
Aaron Hill 2019-09-26 16:17:00 -04:00
parent ddf43867a9
commit e9aa0e7540
No known key found for this signature in database
GPG Key ID: B4087E510E98B164
2 changed files with 4 additions and 3 deletions

View File

@ -15,6 +15,7 @@
use errors::Level;
use errors::Diagnostic;
use errors::FatalError;
use errors::Handler;
use rustc_data_structures::fx::{FxHashMap};
use rustc_data_structures::sync::{Lrc, Lock};
use rustc_data_structures::sharded::Sharded;
@ -321,7 +322,7 @@ pub(super) fn report_cycle(
})
}
pub fn try_print_query_stack() {
pub fn try_print_query_stack(handler: &Handler) {
eprintln!("query stack during panic:");
tls::with_context_opt(|icx| {
@ -336,7 +337,7 @@ pub fn try_print_query_stack() {
query.info.query.name(),
query.info.query.describe(icx.tcx)));
diag.span = icx.tcx.sess.source_map().def_span(query.info.span).into();
icx.tcx.sess.diagnostic().force_print_diagnostic(diag);
handler.force_print_diagnostic(diag);
current_query = query.parent.clone();
i += 1;

View File

@ -1231,7 +1231,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false);
if backtrace {
TyCtxt::try_print_query_stack();
TyCtxt::try_print_query_stack(&handler);
}
#[cfg(windows)]