-
-
Notifications
You must be signed in to change notification settings - Fork 206
wip(native): sync WER data #1760
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
Changes from all commits
a211f3e
df51135
0f60503
bf8b0f7
fa59321
d65d260
e8f51f6
fc07b0b
315f250
765fc5d
bf427a8
54afb7b
5430fe0
3ab8f64
f60abe1
287eeb1
7cbdb44
7f1687c
985abed
4d9c72e
1eebc98
eaa51dc
57185c4
d535b7a
e125ce5
678581b
9dc23d7
d137041
b088def
f38c953
b699bc9
cfb5df9
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 |
|---|---|---|
|
|
@@ -21,6 +21,9 @@ | |
| #include "sentry_utils.h" | ||
| #include "sentry_uuid.h" | ||
| #include "sentry_value.h" | ||
| #if defined(SENTRY_PLATFORM_WINDOWS) | ||
| # include "sentry_wer_report.h" | ||
| #endif | ||
| #include "transports/sentry_disk_transport.h" | ||
|
|
||
| #include <limits.h> | ||
|
|
@@ -2232,6 +2235,41 @@ build_stacktrace_from_ctx(const sentry_crash_context_t *ctx) | |
| return build_stacktrace_for_thread(ctx, SIZE_MAX); | ||
| } | ||
|
|
||
| #if defined(SENTRY_PLATFORM_WINDOWS) | ||
| static bool | ||
| sync_wer_data(sentry_value_t event, const sentry_crash_context_t *ctx) | ||
| { | ||
| if (!ctx->platform.wer_enabled | ||
| || sentry__string_empty(ctx->platform.wer_report_id) | ||
| || (ctx->wer_sync_mode & SENTRY_WER_SYNC_MODE_FROM_WER) == 0) { | ||
| return false; | ||
| } | ||
|
|
||
| char wer_report_id[sizeof(ctx->platform.wer_report_id)]; | ||
| memcpy( | ||
| wer_report_id, ctx->platform.wer_report_id, sizeof(wer_report_id) - 1); | ||
| wer_report_id[sizeof(wer_report_id) - 1] = '\0'; | ||
|
|
||
| sentry_value_t wer_report = sentry__wer_report_lookup(ctx->crash_event_id); | ||
| if (!sentry_value_is_null(wer_report)) { | ||
| sentry__value_merge_objects(event, wer_report); | ||
| sentry_value_decref(wer_report); | ||
| } | ||
|
|
||
| sentry_value_t wer_context = sentry_value_new_object(); | ||
| sentry_value_set_by_key( | ||
| wer_context, "report_id", sentry_value_new_string(wer_report_id)); | ||
|
|
||
| sentry_value_t contexts = sentry_value_get_by_key(event, "contexts"); | ||
| if (sentry_value_get_type(contexts) != SENTRY_VALUE_TYPE_OBJECT) { | ||
| contexts = sentry_value_new_object(); | ||
| sentry_value_set_by_key(event, "contexts", contexts); | ||
| } | ||
| sentry_value_set_by_key(contexts, "wer", wer_context); | ||
| return true; | ||
| } | ||
| #endif | ||
|
|
||
| /** | ||
| * Build native crash event with exception, mechanism, and debug_meta | ||
| * | ||
|
|
@@ -2262,6 +2300,11 @@ build_native_crash_event( | |
| event = sentry_value_new_event(); | ||
| } | ||
|
|
||
| if (!sentry__string_empty(ctx->crash_event_id)) { | ||
| sentry_value_set_by_key( | ||
| event, "event_id", sentry_value_new_string(ctx->crash_event_id)); | ||
| } | ||
|
|
||
| // Set platform to native | ||
| sentry_value_set_by_key( | ||
| event, "platform", sentry_value_new_string("native")); | ||
|
|
@@ -2582,6 +2625,10 @@ build_native_crash_event( | |
| SENTRY_WARN("No modules captured - debug_meta.images will be empty!"); | ||
| } | ||
|
|
||
| #if defined(SENTRY_PLATFORM_WINDOWS) | ||
| sync_wer_data(event, ctx); | ||
| #endif | ||
|
|
||
| return event; | ||
| } | ||
|
|
||
|
|
@@ -2850,18 +2897,28 @@ write_envelope_with_minidump(const sentry_options_t *options, | |
| // Read event JSON data | ||
| size_t event_size = 0; | ||
| char *event_json = NULL; | ||
| char *event_id = NULL; | ||
| const char *event_id = ctx->crash_event_id; | ||
| sentry_path_t *ev_path = sentry__path_from_str(event_msgpack_path); | ||
| if (ev_path) { | ||
| event_json = sentry__path_read_to_buffer(ev_path, &event_size); | ||
| sentry__path_free(ev_path); | ||
| #if defined(SENTRY_PLATFORM_WINDOWS) | ||
| if (event_json && event_size > 0) { | ||
| sentry_value_t event | ||
| = sentry__value_from_json(event_json, event_size); | ||
| event_id = sentry__string_clone(sentry_value_as_string( | ||
| sentry_value_get_by_key(event, "event_id"))); | ||
| if (!sentry_value_is_null(event) && sync_wer_data(event, ctx)) { | ||
| size_t new_event_size = 0; | ||
| char *new_event_json | ||
| = sentry__value_to_json(event, &new_event_size); | ||
| if (new_event_json) { | ||
| sentry_free(event_json); | ||
| event_json = new_event_json; | ||
| event_size = new_event_size; | ||
| } | ||
| } | ||
|
cursor[bot] marked this conversation as resolved.
cursor[bot] marked this conversation as resolved.
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. WER context dropped on JSON failureLow Severity In minidump-only envelope construction, after Reviewed by Cursor Bugbot for commit 9dc23d7. Configure here. |
||
| sentry_value_decref(event); | ||
| } | ||
| #endif | ||
| } | ||
|
|
||
| // Open envelope file for writing | ||
|
|
@@ -2878,7 +2935,6 @@ write_envelope_with_minidump(const sentry_options_t *options, | |
| if (fd < 0) { | ||
| SENTRY_WARN("Failed to open envelope file for writing"); | ||
| sentry_free(event_json); | ||
| sentry_free(event_id); | ||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -2899,7 +2955,6 @@ write_envelope_with_minidump(const sentry_options_t *options, | |
| } else { | ||
| header_len = snprintf(header_buf, sizeof(header_buf), "{}\n"); | ||
| } | ||
| sentry_free(event_id); | ||
| if (header_len > 0 && header_len < (int)sizeof(header_buf)) { | ||
| #if defined(SENTRY_PLATFORM_UNIX) | ||
| if (write(fd, header_buf, header_len) != header_len) { | ||
|
|
@@ -3106,6 +3161,12 @@ sentry__process_crash(const sentry_options_t *options, sentry_crash_ipc_t *ipc) | |
| // Mark as processing | ||
| sentry__atomic_store(&ctx->state, SENTRY_CRASH_STATE_PROCESSING); | ||
| SENTRY_DEBUG("Marked state as PROCESSING"); | ||
| #if defined(SENTRY_PLATFORM_WINDOWS) | ||
| SENTRY_DEBUGF( | ||
| "crash-daemon: processing crash pid=%lu tid=%lu mode=%d wer=%d", | ||
| (unsigned long)ctx->crashed_pid, (unsigned long)ctx->crashed_tid, | ||
| ctx->crash_reporting_mode, ctx->platform.wer_enabled ? 1 : 0); | ||
| #endif | ||
|
|
||
| // Check crash reporting mode | ||
| int mode = ctx->crash_reporting_mode; | ||
|
|
@@ -3117,6 +3178,8 @@ sentry__process_crash(const sentry_options_t *options, sentry_crash_ipc_t *ipc) | |
| // Mode 2 (NATIVE_WITH_MINIDUMP): Write minidump | ||
| bool need_minidump = (mode == SENTRY_CRASH_REPORTING_MODE_MINIDUMP | ||
| || mode == SENTRY_CRASH_REPORTING_MODE_NATIVE_WITH_MINIDUMP); | ||
| SENTRY_DEBUGF("crash-daemon: need_minidump=%d minidump_mode=%d", | ||
| need_minidump ? 1 : 0, ctx->minidump_mode); | ||
|
|
||
| // Determine if we use native stacktrace mode | ||
| // Mode 0: Use minidump-only envelope (existing behavior) | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.