#sentry #minidump #crash #process #capture #reporter #attachment

sentry-rust-minidump

Captures native crashes as minidumps and sends to Sentry

18 releases

0.7.0 Feb 25, 2024
0.6.4 Jul 12, 2023
0.5.1 Mar 11, 2023
0.3.0 Nov 10, 2022
0.1.3 Jul 22, 2022

#135 in Debugging

Download history 185/week @ 2024-01-26 167/week @ 2024-02-02 246/week @ 2024-02-09 285/week @ 2024-02-16 430/week @ 2024-02-23 494/week @ 2024-03-01 1929/week @ 2024-03-08 730/week @ 2024-03-15 547/week @ 2024-03-22 769/week @ 2024-03-29 664/week @ 2024-04-05 468/week @ 2024-04-12 535/week @ 2024-04-19 493/week @ 2024-04-26 441/week @ 2024-05-03 229/week @ 2024-05-10

1,779 downloads per month
Used in sentry-tauri

MIT/Apache

17KB
91 lines

sentry-rust-minidump

Master branch integration test status

Uses the minidumper-child crate to capture minidumps from a separate process and sends them to Sentry as attachments via the Sentry Rust SDK.

sentry_rust_minidump::init starts the current executable again with an argument that causes it to start in crash reporter mode. In this mode it waits for minidump notification from the main app process and handles writing and sending of the minidump file as an attachment to Sentry.

Everything before sentry_rust_minidump::init is called in both the main and crash reporter processes and should configure and start Sentry. Everything after sentry_rust_minidump::init is only called in the main process to run your application code.

[dependencies]
sentry = "0.32"
sentry-rust-minidump = "0.7"
fn main() {
    let client = sentry::init("__YOUR_DSN__");

    // Everything before here runs in both app and crash reporter processes
    let _guard = sentry_rust_minidump::init(&client);
    // Everything after here runs in only the app process

    App::run();

    // This will cause a minidump to be sent to Sentry 
    #[allow(deref_nullptr)]
    unsafe {
        *std::ptr::null_mut() = true;
    }
}

ipc feature

By default there is no scope synchronisation from the app process to the crash reporter process. This means that native crash event will be missing breadcrumbs, user, tags or extra added to the scope in the app.

When the ipc feature is enabled, you can send scope updates to the crash reporter process:

fn main() {
    let client = sentry::init("__YOUR_DSN__");

    // Everything before here runs in both app and crash reporter processes
    let crash_reporter = sentry_rust_minidump::init(&client).expect("crash reported didn't start");
    // Everything after here runs in only the app process

    crash_reporter.add_breadcrumb(...);
    crash_reporter.set_user(...);
    crash_reporter.set_extra(...);
    crash_reporter.set_tag(...);

    // Don't drop crash_reporter or the reporter process will close!
}

Dependencies

~8–19MB
~303K SLoC