From a5f815ddb41facc1d7cb18731de164139f66bca9 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Mon, 7 Sep 2026 10:30:19 +0300 Subject: [PATCH 1/2] fix(native): Resolve the WER module relative to handler_path The native backend looked for sentry-wer.dll only next to the running executable, while the crashpad backend resolves crashpad_wer.dll against handler_path. An embedder that installs the handler in another directory therefore got a working WER module on crashpad and a silent "Native WER module not found" on native. Prefer handler_path's directory and fall back to the executable directory, so existing layouts keep working. Move the existence check into a helper so the fallback is reached when the handler directory holds no module. --- src/backends/sentry_backend_native.c | 40 +++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/backends/sentry_backend_native.c b/src/backends/sentry_backend_native.c index 74156e1af..2bc9cdd1b 100644 --- a/src/backends/sentry_backend_native.c +++ b/src/backends/sentry_backend_native.c @@ -95,8 +95,34 @@ wer_delete_registry_value(const sentry_path_t *wer_path) } static sentry_path_t * -wer_default_path(void) +wer_path_in_dir(const sentry_path_t *dir) { + sentry_path_t *wer_path = sentry__path_join_str(dir, "sentry-wer.dll"); + if (wer_path && sentry__path_is_file(wer_path)) { + return wer_path; + } + sentry__path_free(wer_path); + return NULL; +} + +static sentry_path_t * +wer_module_path(const sentry_options_t *options) +{ + if (options && options->handler_path) { + sentry_path_t *handler_path + = sentry__path_absolute(options->handler_path); + sentry_path_t *handler_dir = sentry__path_dir( + handler_path ? handler_path : options->handler_path); + sentry__path_free(handler_path); + if (handler_dir) { + sentry_path_t *wer_path = wer_path_in_dir(handler_dir); + sentry__path_free(handler_dir); + if (wer_path) { + return wer_path; + } + } + } + sentry_path_t *current_exe = sentry__path_current_exe(); if (!current_exe) { return NULL; @@ -108,7 +134,7 @@ wer_default_path(void) return NULL; } - sentry_path_t *wer_path = sentry__path_join_str(exe_dir, "sentry-wer.dll"); + sentry_path_t *wer_path = wer_path_in_dir(exe_dir); sentry__path_free(exe_dir); return wer_path; } @@ -129,7 +155,7 @@ wer_unregister_module(void) } static bool -wer_register_module(uint64_t app_tid) +wer_register_module(uint64_t app_tid, const sentry_options_t *options) { windows_version_t win_ver; if (!sentry__get_windows_version(&win_ver) || win_ver.build < 19041) { @@ -138,10 +164,9 @@ wer_register_module(uint64_t app_tid) return false; } - sentry_path_t *wer_path = wer_default_path(); - if (!wer_path || !sentry__path_is_file(wer_path)) { + sentry_path_t *wer_path = wer_module_path(options); + if (!wer_path) { SENTRY_WARN("Native WER module not found"); - sentry__path_free(wer_path); return false; } @@ -869,7 +894,8 @@ native_backend_startup( } # if defined(SENTRY_PLATFORM_WINDOWS) && !defined(SENTRY_PLATFORM_XBOX) - state->ipc->shmem->platform.wer_enabled = wer_register_module(tid); + state->ipc->shmem->platform.wer_enabled + = wer_register_module(tid, options); # endif sentry_handler_strategy_t strategy = From 35d08c2c77138fcda9581375b3511d4c56870666 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Mon, 7 Sep 2026 10:39:54 +0300 Subject: [PATCH 2/2] Add changelog entry and apply clang-format --- CHANGELOG.md | 1 + src/backends/sentry_backend_native.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d5d1927c..ff18975dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - Guard size arithmetic when parsing envelopes and Linux OS release data, copying slices, and allocating memory during crash handling. ([#2059](https://github.com/getsentry/sentry-native/pull/2059)) - macOS: prevent out-of-bounds reads while parsing Mach-O load commands. ([#2065](https://github.com/getsentry/sentry-native/pull/2065)) - Prevent out-of-bounds reads when parsing JSON numbers from length-delimited buffers. ([#2067](https://github.com/getsentry/sentry-native/pull/2067)) +- Native/Windows: resolve the WER module relative to `handler_path`, so it is found when the crash handler is installed outside the executable's directory. ([#2073](https://github.com/getsentry/sentry-native/pull/2073)) **Thank you**: diff --git a/src/backends/sentry_backend_native.c b/src/backends/sentry_backend_native.c index 2bc9cdd1b..c0e097d26 100644 --- a/src/backends/sentry_backend_native.c +++ b/src/backends/sentry_backend_native.c @@ -894,8 +894,7 @@ native_backend_startup( } # if defined(SENTRY_PLATFORM_WINDOWS) && !defined(SENTRY_PLATFORM_XBOX) - state->ipc->shmem->platform.wer_enabled - = wer_register_module(tid, options); + state->ipc->shmem->platform.wer_enabled = wer_register_module(tid, options); # endif sentry_handler_strategy_t strategy =