From 425901cf731da483feae093cf3d37518b042b8da Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Mon, 24 Nov 2025 11:21:39 +0000 Subject: [PATCH] crashes: Print panic message to logs (#43159) (cherry-pick to preview) (#43258) Cherry-pick of #43159 to preview ---- Release Notes: - N/A *or* Added/Fixed/Improved ... Co-authored-by: Lukas Wirth --- crates/crashes/src/crashes.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/crashes/src/crashes.rs b/crates/crashes/src/crashes.rs index f1d39afdd9a88eea70466594d04df09e034fc928..baf0bcde3b0769c4fc6cf958c86e181cda615683 100644 --- a/crates/crashes/src/crashes.rs +++ b/crates/crashes/src/crashes.rs @@ -51,11 +51,13 @@ pub async fn init(crash_init: InitCrashHandler) { unsafe { env::set_var("RUST_BACKTRACE", "1") }; old_hook(info); // prevent the macOS crash dialog from popping up - std::process::exit(1); + if cfg!(target_os = "macos") { + std::process::exit(1); + } })); return; } - (Some(true), _) | (None, _) => { + _ => { panic::set_hook(Box::new(panic_hook)); } } @@ -300,11 +302,18 @@ pub fn panic_hook(info: &PanicHookInfo) { .map(|loc| format!("{}:{}", loc.file(), loc.line())) .unwrap_or_default(); + let current_thread = std::thread::current(); + let thread_name = current_thread.name().unwrap_or(""); + // wait 500ms for the crash handler process to start up // if it's still not there just write panic info and no minidump let retry_frequency = Duration::from_millis(100); for _ in 0..5 { if let Some(client) = CRASH_HANDLER.get() { + let location = info + .location() + .map_or_else(|| "".to_owned(), |location| location.to_string()); + log::error!("thread '{thread_name}' panicked at {location}:\n{message}..."); client .send_message( 2,