feat(crash): Breakpad-style minidumps on macOS and Windows
Ghostty links sentry-native with the breakpad backend on every platform (SharedDeps.zig), so it writes minidumps on macOS and Windows as well. - macOS: a Mach exception port handler thread (structured like Breakpad's exception_handler) catches EXC_BAD_ACCESS/BAD_INSTRUCTION/ ARITHMETIC/BREAKPOINT, suspends other threads, reads the crashed thread state and writes a minidump via minidump-writer as the event.minidump attachment, then restores the previous ports so the BSD signal and default termination follow. The signal path remains the fallback (and handles SIGABRT); a watchdog alarm bounds dumping. - Windows: SetUnhandledExceptionFilter hands off to a pre-started dump thread using minidump-writer's dump_crash_context. - The screen-file open action decodes the escaped path to raw OS bytes (also for the C action passed to embedders). macOS/Windows code is compile-checked (clippy -D warnings) only; the shared Mach message decoding and minidump attachment logic have Linux unit tests. Platform matrix in docs/rewrite/notes/crash-CR.md. Test Plan: - cargo test --workspace (3348 passed) - just check-macos; just check-macos x86_64-apple-darwin; just check-windows
This commit is contained in:
1 parent
41e0b9cb68
commit
b1ad29fa97
12 files changed
+914
-34
No files matched your search
@@ -49,7 +49,7 @@ static SCRATCH: ScratchCell = ScratchCell(UnsafeCell::new(Scratch {
|
||||
#[cfg(target_vendor = "apple")]
|
||||
native: crate::native::Native::new(),
|
||||
}));
|
||||
static BUSY: AtomicBool = AtomicBool::new(false);
|
||||
pub(crate) static BUSY: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
/// A `fmt::Write` into a fixed byte slice; errors when full.
|
||||
struct SliceWriter<'a> {
|
||||
@@ -302,4 +302,11 @@ pub(crate) fn install_handlers() {
|
||||
libc::sigaction(sig, &raw const sa, std::ptr::null_mut());
|
||||
}
|
||||
}
|
||||
// macOS: memory faults are Mach exceptions first; the exception port
|
||||
// handler writes the minidump (see `mach_handler`). The signal handlers
|
||||
// above stay as the path for SIGABRT and as a fallback.
|
||||
#[cfg(target_os = "macos")]
|
||||
if !crate::mach_handler::install() {
|
||||
log::warn!("mach exception port handler unavailable; using signal handlers only");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user