diff --git a/src/bin/consciousness.rs b/src/bin/consciousness.rs index 2fcfebf..61d28e1 100644 --- a/src/bin/consciousness.rs +++ b/src/bin/consciousness.rs @@ -2,6 +2,17 @@ #![warn(unreachable_pub)] fn main() { + // Force the default panic hook to print a backtrace. stderr is + // already redirected to a daemon log; without this the hook obeys + // RUST_BACKTRACE (unset by default), so the log only shows the + // "note: run with `RUST_BACKTRACE=full`" tail and the actual + // frames are lost. + // + // SAFETY: called before any other thread is spawned, so no + // concurrent env reader can race. + if std::env::var_os("RUST_BACKTRACE").is_none() { + unsafe { std::env::set_var("RUST_BACKTRACE", "1"); } + } std::panic::set_backtrace_style(std::panic::BacktraceStyle::Short); consciousness::user::main() }