Skip to content

wip(native): sync WER data#1760

Closed
jpnurmi wants to merge 32 commits into
masterfrom
jpnurmi/feat/native/wer-metadata
Closed

wip(native): sync WER data#1760
jpnurmi wants to merge 32 commits into
masterfrom
jpnurmi/feat/native/wer-metadata

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented May 27, 2026

App:

WerRegisterCustomMetadata(L"foo", L"ooo");
WerRegisterCustomMetadata(L"bar", L"aaa");
WerRegisterCustomMetadata(L"baz", L"zzz");

Context:

{
  "contexts": {
    "wer": {
      "type": "wer",
      "report_id": "...",
      "metadata": {
        "foo": "ooo",
        "bar": "aaa",
        "baz": "zzz"
      }
    }
  }
}

Sentry:
image

Comment thread src/backends/native/sentry_crash_daemon.c
Comment thread src/backends/native/sentry_wer_report.c
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/native/wer-metadata branch from c9a7b1a to c218239 Compare May 27, 2026 07:27
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 27, 2026

TGDX-58

@jpnurmi jpnurmi changed the title feat(native): capture WER custom metadata wip(native): capture WER custom metadata May 27, 2026
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/native/wer-metadata branch from c218239 to b503ec0 Compare May 27, 2026 14:36
Comment thread src/backends/native/sentry_crash_daemon.c
Comment thread src/backends/native/sentry_wer.c
@jpnurmi jpnurmi closed this May 28, 2026
@jpnurmi jpnurmi deleted the jpnurmi/feat/native/wer-metadata branch May 28, 2026 06:56
@jpnurmi jpnurmi reopened this May 29, 2026
Comment thread src/backends/native/sentry_crash_daemon.c Outdated
Comment thread src/backends/native/sentry_crash_daemon.c
Comment thread src/backends/native/sentry_crash_daemon.c Outdated
Comment thread src/backends/native/sentry_wer.c
Comment thread src/backends/native/sentry_wer_report.c
Comment thread src/backends/native/sentry_crash_daemon.c Outdated
Comment thread src/backends/native/sentry_wer.c
Comment thread src/backends/native/sentry_crash_handler.c
Comment thread src/backends/native/sentry_wer.c Outdated
jpnurmi added 12 commits June 1, 2026 15:00
Pre-generate the native crash event ID and register it as WER custom
metadata so the crash daemon can identify the matching
WERInternalMetadata.xml.

Store the WER report ID provided by sentry-wer.dll in the shared crash
context and add a wer context with the report ID and app-provided WER
custom metadata.
The crash handler's WER path returned EXCEPTION_CONTINUE_SEARCH without
claiming the crash state or signaling the daemon, relying entirely on the
sentry-wer DLL callback to do so via WER. On CI runners WER may not
always invoke the registered callback, leaving the daemon waiting
indefinitely. Fix by having the crash handler always claim the crash
state and notify the daemon before returning, and having the sentry-wer
DLL write the WER report ID and signal even when the crash handler
already claimed the crash.
When the crash handler claims the crash in the WER path and notifies
the daemon, it must set exception_pointers to NULL so the daemon uses
the already-copied exception record/context from shared memory with
ClientPointers=FALSE. Otherwise MiniDumpWriteDump tries to read from
the crashed process's address space (ClientPointers=TRUE), but the
process is already terminated because the crash handler returned
EXCEPTION_CONTINUE_SEARCH without waiting.
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/native/wer-metadata branch from e7a5ac6 to 985abed Compare June 1, 2026 13:01
Comment thread src/backends/native/sentry_wer.c
Comment thread src/backends/native/sentry_crash_handler.c Outdated
@jpnurmi jpnurmi changed the title wip(native): capture WER custom metadata wip(native): sync WER data Jun 1, 2026
Comment thread src/backends/native/sentry_crash_handler.c
Comment thread src/backends/sentry_backend_native.c

from ast import pattern
import os
from pydoc import text
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray unused test imports

Low Severity

The integration test file adds from ast import pattern and from pydoc import text, which are not used anywhere in the module. The WER helper uses a local variable named text, not the pydoc import. These look like accidental editor additions unrelated to the WER sync work.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 678581b. Configure here.

This reverts commit 985abed.
Comment thread src/backends/sentry_backend_native.c
envelope = Envelope.deserialize(httpserver.log[0][0].get_data())
assert_native_crash(envelope, exception_code=0xC0000409)

event = envelope.get_event()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong exception code for fastfail

Low Severity

test_native_wer always asserts exception code 0xC0000409 while also parametrizing crash_arg with fastfail, but __fastfail crashes use STATUS_FAIL_FAST_EXCEPTION (0xC0000602), so the fastfail case fails the mechanism check.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9dc23d7. Configure here.

event_json = new_event_json;
event_size = new_event_size;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WER context dropped on JSON failure

Low Severity

In minidump-only envelope construction, after add_wer_context mutates the parsed event, a failed sentry__value_to_json leaves the original on-disk JSON unchanged, so the uploaded envelope can omit the WER context even though enrichment succeeded in memory.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9dc23d7. Configure here.

sentry_value_decref(tags);
}

return event;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WER parser omits report_id

Medium Severity

parse_internal_metadata only copies ProcessMetadata into top-level tags and never builds contexts.wer.report_id from ReportInformation/Guid, but the new wer_metadata unit test expects that shape from sentry__wer_report_from_buffer.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b088def. Configure here.

// the crash first, it already SetEvent'd via sentry__crash_ipc_notify,
// but a redundant SetEvent on an auto-reset event is harmless.
if (SetEvent(event)) {
claimed = TRUE;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WER claim omits process termination

High Severity

The WER callback still transitions shared crash state to CRASHED and sets ownership_claimed when it wins the claim, but this change removed the prior TerminateProcess (and wait-for-daemon) that ran after a successful claim, so fail-fast paths handled only by WER may never exit.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b088def. Configure here.

Comment thread src/backends/native/sentry_wer.c
Comment thread src/backends/sentry_backend_native.c
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 6 total unresolved issues (including 5 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a6f70e9. Configure here.

Comment thread src/backends/sentry_backend_native.c Outdated
Comment thread src/backends/sentry_backend_native.c Outdated
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/native/wer-metadata branch from a6f70e9 to cfb5df9 Compare June 1, 2026 19:51
@jpnurmi
Copy link
Copy Markdown
Collaborator Author

jpnurmi commented Jun 3, 2026

Superceded by #1777

@jpnurmi jpnurmi closed this Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant