fix: event ownership in sentry_capture_minidump#1669
Open
Conversation
Collaborator
Author
|
All tsan and asan jobs fail without the fix: https://github.com/getsentry/sentry-native/actions/runs/24885938040 |
After sentry__prepare_event returns, the event is either already cleaned up on its failure path (envelope == NULL) or owned by the envelope via sentry__envelope_add_event (envelope != NULL). The fallback `sentry_value_decref(event)` therefore always double-decrefs the event, and in the `envelope != NULL && nil event_id` sub-case it additionally leaks the envelope itself. Replace with `sentry_envelope_free(envelope)`, which is a no-op on NULL and releases the owned event via item teardown. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Exercises the `!envelope` branch of sentry_capture_minidump_n by discarding the event via a before_send hook. Without the ownership fix, the branch double-decrefs the event (and leaks the envelope in the non-null-envelope sub-case); ASan/valgrind in CI trips on it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
7ee7b39 to
4ba76e8
Compare
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.
In
sentry_capture_minidump_n, the!envelope || sentry_uuid_is_nil(&event_id)branch incorrectly calledsentry_value_decref(event).After
sentry__prepare_eventreturns,eventis either:a) already cleaned up by its fail path (
envelope == NULL), orb) owned by the envelope via
sentry__envelope_add_event(envelope != NULL).The
decrefis therefore always a double-decref, and for the non-null-envelope sub-case additionally leaks the envelope. Replace withsentry_envelope_free(envelope)— no-op onNULL, releases the owned event via item teardown otherwise.The newly added test fails with the CI jobs that run with sanitizers: https://github.com/getsentry/sentry-native/actions/runs/24885938040
Came up in #1545