From bd69124f2b4f14911483135b4cbd42e0766bea3d Mon Sep 17 00:00:00 2001 From: Nia Date: Wed, 22 Oct 2025 13:04:58 +0200 Subject: [PATCH] Add option to disable crash handler (#40799) Extra info needed for #39289. To be tested out next nightly build... Release Notes: - N/A Co-authored-by: Cole Miller --- crates/crashes/src/crashes.rs | 36 ++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/crates/crashes/src/crashes.rs b/crates/crashes/src/crashes.rs index 4a45961970cf009ef2a47d5562c1df1792a90aec..62455d552e860b1b00ec0c770d61dd6f03f908fd 100644 --- a/crates/crashes/src/crashes.rs +++ b/crates/crashes/src/crashes.rs @@ -33,17 +33,31 @@ const CRASH_HANDLER_CONNECT_TIMEOUT: Duration = Duration::from_secs(10); static PANIC_THREAD_ID: AtomicU32 = AtomicU32::new(0); pub async fn init(crash_init: InitCrashHandler) { - if *RELEASE_CHANNEL == ReleaseChannel::Dev && env::var("ZED_GENERATE_MINIDUMPS").is_err() { - let old_hook = panic::take_hook(); - panic::set_hook(Box::new(move |info| { - unsafe { env::set_var("RUST_BACKTRACE", "1") }; - old_hook(info); - // prevent the macOS crash dialog from popping up - std::process::exit(1); - })); - return; - } else { - panic::set_hook(Box::new(panic_hook)); + let gen_var = match env::var("ZED_GENERATE_MINIDUMPS") { + Ok(v) => { + if v == "false" || v == "0" { + Some(false) + } else { + Some(true) + } + } + Err(_) => None, + }; + + match (gen_var, *RELEASE_CHANNEL) { + (Some(false), _) | (None, ReleaseChannel::Dev) => { + let old_hook = panic::take_hook(); + panic::set_hook(Box::new(move |info| { + unsafe { env::set_var("RUST_BACKTRACE", "1") }; + old_hook(info); + // prevent the macOS crash dialog from popping up + std::process::exit(1); + })); + return; + } + (Some(true), _) | (None, _) => { + panic::set_hook(Box::new(panic_hook)); + } } let exe = env::current_exe().expect("unable to find ourselves");