Skip to content

WIP: feat: WER integration#1837

Open
jpnurmi wants to merge 39 commits into
masterfrom
jpnurmi/feat/wer-integration
Open

WIP: feat: WER integration#1837
jpnurmi wants to merge 39 commits into
masterfrom
jpnurmi/feat/wer-integration

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

The WER (Windows Error Reporting) integration:

  • enabled via cmake -DSENTRY_INTEGRATION_WER=ON (inspired by the existing Qt integration)
  • automatically wired up during sentry_init
  • based on the scope observer API (sentry_scope_observer_t, also WIP)
  • syncs tags and attachments to WER
    • WerRegisterCustomMetadata / WerUnregisterCustomMetadata (Windows 10 1703+)
    • WerRegisterFile / WerUnregisterFile
    • WerRegisterMemoryBlock / WerUnregisterMemoryBlock

The implementation is backend-agnostic, but does not work with breakpad or crashpad, which prevent WER from handling the exception.

> pytest -v --with_wer tests\test_integration_wer.py
=================================================================== test session starts ====================================================================
platform win32 -- Python 3.13.3, pytest-9.0.3, pluggy-1.6.0 -- C:\Users\jpnurmi\Projects\sentry\sentry-native\.venv\Scripts\python.exe
cachedir: .pytest_cache
rootdir: C:\Users\jpnurmi\Projects\sentry\sentry-native
plugins: flaky-3.8.1, pytest_httpserver-1.0.10, xdist-3.8.0
collected 5 items

tests/test_integration_wer.py::test_wer_custom_metadata[none] PASSED                                                                                  [ 20%]
tests/test_integration_wer.py::test_wer_custom_metadata[inproc] PASSED                                                                                [ 40%]
tests/test_integration_wer.py::test_wer_custom_metadata[breakpad] XFAIL (breakpad swallows the exception)                                             [ 60%]
tests/test_integration_wer.py::test_wer_custom_metadata[crashpad] XFAIL (crashpad handler terminates the process)                                     [ 80%]
tests/test_integration_wer.py::test_wer_custom_metadata[native] PASSED                                                                                [100%]

@jpnurmi jpnurmi marked this pull request as draft July 2, 2026 13:52
Comment thread src/integrations/sentry_integration_wer.c
Comment thread src/sentry_scope.c Outdated
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/wer-integration branch from de2ad2d to dac6b6c Compare July 6, 2026 16:23
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/wer-integration branch from 75d0c15 to c7fc095 Compare July 6, 2026 18:46
@jpnurmi jpnurmi marked this pull request as ready for review July 6, 2026 18:48
Comment thread src/integrations/sentry_integration_wer.c
Comment thread src/integrations/sentry_integration_wer.c
Comment thread src/sentry_scope.c Outdated
Comment thread src/sentry_scope.c Outdated
Comment thread src/integrations/sentry_integration_wer.c
jpnurmi added 4 commits July 7, 2026 10:27
Adds a sentry_integration_t struct with a register_func callback that is
called from sentry_init() while the scope lock is held. Integrations can
use this to create and register scope observers.

sentry_options_add_integration() stores integrations in options, which
takes ownership. An optional free_func is called before the integration
struct is freed.
Adds sentry_integration_wer_new() which creates an integration that uses
a scope observer to sync sentry scope state to Windows Error Reporting:

- Tags are synced via WerRegisterCustomMetadata (loaded dynamically for
  compatibility with pre-19H1 Windows 10 builds).
- File attachments are registered with WerRegisterFile.
- Buffer attachments are registered with WerRegisterMemoryBlock.

When tags or attachments are removed via the sentry API, the
corresponding WER registrations are cleaned up.
jpnurmi added 19 commits July 7, 2026 12:35
Replace the generic sentry_integration_t approach with a simpler pattern
matching the existing Qt integration (SENTRY_INTEGRATION_QT):

- Remove sentry_integration_t, sentry_options_add_integration(), and all
  the dynamic array management in options.
- Add a SENTRY_INTEGRATION_WER CMake option that conditionally compiles
  the WER integration source and sets the compile definition.
- sentry_integration_setup_wer(scope, options) is called from
  sentry_init() inside SENTRY_WITH_SCOPE_MUT.
- The WER integration uses static globals for wer.dll function pointers
  instead of a heap-allocated state struct.
The source file is already guarded with #ifdef SENTRY_PLATFORM_WINDOWS,
so it quietly becomes a no-op on other platforms without needing a
FATAL_ERROR.
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/wer-integration branch from 48dffcf to 6b31a5c Compare July 7, 2026 11:36

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

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 6b31a5c. Configure here.

const char *key, sentry_value_t UNUSED(value), void *data)
{
wer_remove_tag(data, key, strlen(key));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cleanup uses strlen on tag keys

Low Severity

wer_cleanup_tag passes strlen(key) into wer_remove_tag during shutdown cleanup, while tag set/remove paths use explicit key_len from sentry_set_tag_n / sentry_remove_tag_n. Keys stored with embedded NUL bytes can unregister under the wrong WER metadata name.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6b31a5c. Configure here.

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