diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-10-05 14:11:37 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-10-05 14:27:47 -0400 |
commit | cfa54cabbdaca48d7623cd5fd5aada59b5e02040 (patch) | |
tree | 668fed8714d333bf12c184ffb4e2db3f81c4caf3 /src/main.rs | |
parent | ab952e33405309b723f219c5c74243f0eeb7dba7 (diff) |
Always die on panic.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index bec97ea60..f6c85ef83 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); |