From cfa54cabbdaca48d7623cd5fd5aada59b5e02040 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 5 Oct 2018 14:11:37 -0400 Subject: [PATCH] Always die on panic. --- src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.rs b/src/main.rs index bec97ea605..f6c85ef831 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,6 +54,18 @@ impl log::Log for Logger { } fn main() { + // Rust does not die on panic by default. And -Cpanic=abort is broken. + // https://github.com/rust-lang/cargo/issues/2738 + // Therefore this hack. + std::panic::set_hook(Box::new(|panic_info| { + if let Some(location) = panic_info.location() { + println!("PANIC file '{}' line {}", location.file(), location.line()); + } else { + println!("PANIC occurred but can't get location information..."); + } + std::process::abort(); + })); + log::set_logger(&LOGGER).unwrap(); let args = env::args().collect(); let mut isolate = isolate::Isolate::new(args, ops::dispatch);