fix(native): external crash reporter#1589
Merged
Merged
Conversation
The native backend's crash daemon now invokes `sentry__launch_external_crash_reporter()` after processing a crash, writing the envelope to the external directory and spawning the configured reporter process. When an external reporter is configured, the daemon does not send envelopes via its own transport. Refactored `sentry__launch_external_crash_reporter()` to accept `options` directly instead of using `SENTRY_WITH_OPTIONS` (which relies on global state unavailable in the daemon process), and to use `sentry__transport_send_envelope()` directly to bypass the consent check in `sentry__capture_envelope()` since upload consent is the external reporter's concern. Also adds event_id to the envelope headers written by the daemon's crash processing functions, and removes the incomplete session-only envelope that `native_backend_flush_scope` was writing to the external directory. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
05a8064 to
a626e07
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Autofix Details
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Double-free of envelope after external crash reporter
- I removed the daemon-side free in the external-crash-reporter success path so envelope ownership remains with the external disk transport.
- ✅ Fixed: Memory leak of
event_jsonon error path- I now free
event_jsonwhen envelope file open fails and unconditionally after event writing so all paths release the buffer.
- I now free
Or push these changes by commenting:
@cursor push e794f41a23
Preview (e794f41a23)
diff --git a/src/backends/native/sentry_crash_daemon.c b/src/backends/native/sentry_crash_daemon.c
--- a/src/backends/native/sentry_crash_daemon.c
+++ b/src/backends/native/sentry_crash_daemon.c
@@ -2280,6 +2280,7 @@
if (fd < 0) {
SENTRY_WARN("Failed to open envelope file for writing");
sentry_free(event_id);
+ sentry_free(event_json);
return false;
}
@@ -2333,8 +2334,8 @@
_write(fd, "\n", 1);
#endif
}
- sentry_free(event_json);
}
+ sentry_free(event_json);
// Add minidump as attachment
#if defined(SENTRY_PLATFORM_UNIX)
@@ -2750,8 +2751,6 @@
SENTRY_WARN("No transport available for sending envelope");
sentry_envelope_free(envelope);
}
- } else {
- sentry_envelope_free(envelope);
}
// Clean up temporary envelope file (keep minidump forThis Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
mujacica
approved these changes
Mar 23, 2026
1 task
BernhardMarconato
pushed a commit
to elgatosf/sentry-native
that referenced
this pull request
Apr 21, 2026
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


The native backend's crash daemon now invokes
sentry__launch_external_crash_reporter()after processing a crash, writing the envelope to the external directory and spawning the configured reporter process. When an external reporter is configured, the daemon does not send envelopes via its own transport.Refactored
sentry__launch_external_crash_reporter()to acceptoptionsdirectly instead of usingSENTRY_WITH_OPTIONS(which relies on global state unavailable in the daemon process), and to usesentry__transport_send_envelope()directly to bypass the consent check insentry__capture_envelope()since upload consent is the external reporter's concern.Also adds
event_idto the envelope headers written by the daemon's crash processing functions, and removes the incomplete session-only envelope thatnative_backend_flush_scopewas writing to the external directory.