---
title: "Native Crash Reporting"
description: "Learn how to capture native crashes, such as segmentation faults, from your Rust application as minidumps."
url: https://docs.sentry.io/platforms/rust/guides/axum/native-crash-reporting/
---

# Native Crash Reporting for axum

The SDK reports panics automatically, but some crashes aren't panics. For example, a segmentation fault in `unsafe` code or in a C library called through FFI kills your process without running Rust's panic handling. The minidump integration captures these native crashes as [minidumps](https://docs.sentry.io/platforms/native/guides/minidumps.md#what-is-a-minidump) and sends them to Sentry.

##### A Word on Data Privacy

Minidumps are memory dumps of the process at the moment it crashes. As such, they might contain sensitive information on the target system, such as environment variables, local pathnames or maybe even in-memory representations of input fields, including passwords. **Sentry does not store these memory dumps by default**. Once processed, they are removed immediately, and all sensitive information is stripped from the resulting issues.

You can configure Sentry to [store minidumps as attachments](https://docs.sentry.io/platforms/native/guides/minidumps.md#store-minidumps-as-attachments).

## [Requirements](https://docs.sentry.io/platforms/rust/guides/axum/native-crash-reporting.md#requirements)

* Sentry Rust SDK version `0.49.3` or later.
* Linux, macOS, or Windows. On other targets, the `minidump` feature has no effect.

## [Setup](https://docs.sentry.io/platforms/rust/guides/axum/native-crash-reporting.md#setup)

Enable the `minidump` feature in your `Cargo.toml`:

```toml
[dependencies]
sentry = { version = "0.49.3", features = ["minidump"] }
```

Then, add the [`MinidumpIntegration`](https://docs.rs/sentry-minidump/latest/sentry_minidump/struct.MinidumpIntegration.html) when you initialize the SDK at the start of `main`:

```rust
use sentry::integrations::minidump::MinidumpIntegration;

fn main() {
    let _guard = sentry::init(
        sentry::ClientOptions::new()
            .dsn("https://<key>@o<orgId>.ingest.sentry.io/<projectId>")
            .add_integration(MinidumpIntegration::new()),
    );

    // Your app code goes here.
}
```

## [How It Works](https://docs.sentry.io/platforms/rust/guides/axum/native-crash-reporting.md#how-it-works)

When you call `sentry::init`, the integration starts a separate crash reporter process by running your app's binary a second time. If your app crashes, the crash reporter writes a minidump and sends it to Sentry as a fatal event, with the minidump attached. The crash reporter uses the same client options as your app, so options such as `release` and `environment` also apply to crash events.

Because the crash reporter runs your binary:

* Any code before `sentry::init` runs in both processes.
* In the crash reporter process, `sentry::init` never returns, so code after it only runs in your app.
* Only one crash reporter runs per process. Calling `sentry::init` again doesn't start another one.

If you need to run code before `sentry::init`, use `is_crash_reporter_process` to skip work that should only happen in your app:

```rust
use sentry::integrations::minidump::MinidumpIntegration;

fn main() {
    let minidump = MinidumpIntegration::new();

    if !minidump.is_crash_reporter_process() {
        // App-only setup, for example, writing a PID file.
    }

    let _guard = sentry::init(
        sentry::ClientOptions::new()
            .dsn("https://<key>@o<orgId>.ingest.sentry.io/<projectId>")
            .add_integration(minidump),
    );
}
```

## [Add Context to Crash Reports](https://docs.sentry.io/platforms/rust/guides/axum/native-crash-reporting.md#add-context-to-crash-reports)

The crash reporter can't read your app's scope, so data you set with functions like `sentry::configure_scope` isn't included in crash events. To add the user, tags, extra data, or breadcrumbs to crash events, send them to the crash reporter through the integration after you initialize the SDK:

```rust
use sentry::integrations::minidump::MinidumpIntegration;

fn main() {
    let _guard = sentry::init(/* ... as above ... */);

    sentry::with_integration(|minidump: &MinidumpIntegration, _| {
        minidump.set_user(Some(sentry::User {
            id: Some("42".into()),
            ..Default::default()
        }));
        minidump.set_tag("my_tag".into(), Some("my_value".into()));
    });
}
```

## [Symbolication](https://docs.sentry.io/platforms/rust/guides/axum/native-crash-reporting.md#symbolication)

To show function names and source locations in crash stack traces, Sentry needs your app's debug information files. Follow the steps in [Source Context](https://docs.sentry.io/platforms/rust/guides/axum/source-context.md) to create and upload them. To learn more, see [Debug Information Files](https://docs.sentry.io/platforms/native/data-management/debug-files.md).

## [Next Steps](https://docs.sentry.io/platforms/rust/guides/axum/native-crash-reporting.md#next-steps)

To configure the minidump directory, upload timeout, crash reporter process name, and more, see the [`sentry-minidump` API docs](https://docs.rs/sentry-minidump/latest/sentry_minidump/).
