-
-
Notifications
You must be signed in to change notification settings - Fork 204
WIP: fix(tracing): finish active trace on crash #1667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
87d7ace
47e5333
682f690
973c30d
cb56743
2691500
60418f0
177c83f
364f1cc
93f41bb
92e4b3c
264a69b
ba3de42
3266a8e
ceb302a
6a2e71b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
| #include "sentry_scope.h" | ||
| #include "sentry_session.h" | ||
| #include "sentry_sync.h" | ||
| #include "sentry_tracing.h" | ||
| #include "sentry_transport.h" | ||
| #include "transports/sentry_disk_transport.h" | ||
|
|
||
|
|
@@ -847,6 +848,9 @@ native_backend_except(sentry_backend_t *backend, const sentry_ucontext_t *uctx) | |
| // Write crash marker | ||
| sentry__write_crash_marker(options); | ||
|
|
||
| sentry_value_t transaction | ||
| = sentry__trace_finish(SENTRY_SPAN_STATUS_ABORTED); | ||
|
|
||
| // Create crash event | ||
| sentry_value_t event = sentry_value_new_event(); | ||
| sentry_value_set_by_key( | ||
|
|
@@ -948,26 +952,33 @@ native_backend_except(sentry_backend_t *backend, const sentry_ucontext_t *uctx) | |
| = sentry__end_current_session_with_status( | ||
| SENTRY_SESSION_STATUS_CRASHED); | ||
|
|
||
| if (session) { | ||
| sentry_envelope_t *envelope = sentry__envelope_new(); | ||
| if (envelope) { | ||
| sentry__envelope_add_session(envelope, session); | ||
|
|
||
| // Write session envelope to disk | ||
| sentry_transport_t *disk_transport | ||
| = sentry_new_disk_transport(options->run); | ||
| if (disk_transport) { | ||
| // sentry__capture_envelope takes ownership of | ||
| // envelope | ||
| sentry__capture_envelope( | ||
| disk_transport, envelope, options); | ||
| sentry__transport_dump_queue( | ||
| disk_transport, options->run); | ||
| sentry_transport_free(disk_transport); | ||
| } else { | ||
| // Failed to create transport, free envelope | ||
| sentry_envelope_free(envelope); | ||
| if (session || !sentry_value_is_null(transaction)) { | ||
| sentry_transport_t *disk_transport | ||
| = sentry_new_disk_transport(options->run); | ||
| if (disk_transport) { | ||
| if (!sentry_value_is_null(transaction)) { | ||
| sentry_envelope_t *tx_envelope | ||
| = sentry__prepare_transaction( | ||
| options, transaction, NULL); | ||
| if (tx_envelope) { | ||
| sentry__capture_envelope( | ||
| disk_transport, tx_envelope, options); | ||
| } | ||
| } | ||
| if (session) { | ||
| sentry_envelope_t *envelope | ||
| = sentry__envelope_new(); | ||
| if (envelope) { | ||
| sentry__envelope_add_session(envelope, session); | ||
| sentry__capture_envelope( | ||
| disk_transport, envelope, options); | ||
| } | ||
| } | ||
| sentry__transport_dump_queue( | ||
| disk_transport, options->run); | ||
| sentry_transport_free(disk_transport); | ||
| } else { | ||
| sentry_value_decref(transaction); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Session leaked when disk transport creation failsLow Severity The refactor moves Reviewed by Cursor Bugbot for commit 6a2e71b. Configure here. |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -980,6 +991,7 @@ native_backend_except(sentry_backend_t *backend, const sentry_ucontext_t *uctx) | |
| } else { | ||
| SENTRY_DEBUG("event was discarded by the `on_crash` hook"); | ||
| sentry_value_decref(event); | ||
| sentry_value_decref(transaction); | ||
| } | ||
| } | ||
| } | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
External crash reporter drops finished transaction
Medium Severity
The
transactionvalue fromsentry__trace_finishis leaked and its trace is not sent in crash handling. This occurs when an external crash reporter is launched (ininprocandbreakpadbackends) or when thebefore_send_funchook discards the crash event (in thenativebackend), as the transaction is not properly managed in these paths.Additional Locations (1)
src/backends/sentry_backend_native.c#L869-L995Reviewed by Cursor Bugbot for commit 6a2e71b. Configure here.