From 2fccaae9f195140dd4718a7c33761258142fe0c1 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 27 Nov 2026 16:57:25 +0100 Subject: [PATCH 1/3] fix(native): retry Windows minidumps with the copied exception context The minidump-only cases of `test_native_scope_updates_without_snapshot` fail on some `windows-2022` runners with `AssertionError: Wait timeout occurred`, because the daemon drops the crash: MiniDumpWriteDump failed: 2147942699 Minidump mode requires minidump, but minidump failed `0x8007012B` is `ERROR_PARTIAL_COPY`. With `ClientPointers=TRUE`, dbghelp reads the remote context sized by the enabled XSTATE features. With AMX enabled (XSTATE `0x608e7`), that is 11.3 KiB, which runs past the 6.6-8.0 KiB of stack above the context of this shallow crash. Retry with the copied exception record and context, as the WER path already does, and as Crashpad reads only `sizeof(CONTEXT)` of the exception context. Clear `CONTEXT_XSTATE` in the copy, which only holds `sizeof(CONTEXT)`. On an AMX runner, all 10 minidump-only crashes then produced a minidump. Failures: - https://github.com/getsentry/sentry-native/actions/runs/43460190688/job/132004723418 - https://github.com/getsentry/sentry-native/actions/runs/44277473923/job/134709168872 - https://github.com/getsentry/sentry-native/actions/runs/44277473923/job/134709168940 - https://github.com/getsentry/sentry-native/actions/runs/44509847830/job/135510909755 - https://github.com/getsentry/sentry-native/actions/runs/45645459970/job/139315482377 - https://github.com/getsentry/sentry-native/actions/runs/45789616342/job/139805024432 - https://github.com/getsentry/sentry-native/actions/runs/45972837352/job/140473685255 Verification: https://github.com/getsentry/sentry-native/actions/runs/46023305396/job/140596731823 --- .../native/minidump/sentry_minidump_windows.c | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/backends/native/minidump/sentry_minidump_windows.c b/src/backends/native/minidump/sentry_minidump_windows.c index f32a6307bd..20bc02e845 100644 --- a/src/backends/native/minidump/sentry_minidump_windows.c +++ b/src/backends/native/minidump/sentry_minidump_windows.c @@ -102,7 +102,16 @@ sentry__write_minidump( // Prepare exception information using original pointers from crashed // process EXCEPTION_POINTERS local_exception_pointers = { 0 }; - EXCEPTION_RECORD local_exception_record = { 0 }; + EXCEPTION_RECORD local_exception_record = ctx->platform.exception_record; + local_exception_record.ExceptionRecord = NULL; + CONTEXT local_context = ctx->platform.context; +# ifdef CONTEXT_XSTATE + // Only sizeof(CONTEXT) is copied, without the extended state. Clear its + // flag but keep the architecture bit that CONTEXT_XSTATE includes. + local_context.ContextFlags &= ~(CONTEXT_XSTATE & ~CONTEXT_CONTROL); +# endif + local_exception_pointers.ExceptionRecord = &local_exception_record; + local_exception_pointers.ContextRecord = &local_context; MINIDUMP_EXCEPTION_INFORMATION exception_info = { 0 }; exception_info.ThreadId = ctx->crashed_tid; if (ctx->platform.exception_pointers) { @@ -114,11 +123,6 @@ sentry__write_minidump( } else { // WER copies exception data into shared memory, so ClientPointers must // be false when using the copied record/context. - local_exception_record = ctx->platform.exception_record; - local_exception_record.ExceptionRecord = NULL; - local_exception_pointers.ExceptionRecord = &local_exception_record; - local_exception_pointers.ContextRecord - = (PCONTEXT)&ctx->platform.context; exception_info.ExceptionPointers = &local_exception_pointers; exception_info.ClientPointers = FALSE; } @@ -129,6 +133,22 @@ sentry__write_minidump( DWORD error = GetLastError(); + if (!success && exception_info.ClientPointers) { + // dbghelp may fail to read the remote context, e.g. when the enabled + // XSTATE features (AMX) extend it past the top of the crashed stack. + // Retry with the copied record/context. + SENTRY_WARNF( + "MiniDumpWriteDump failed with client pointers: %lu", error); + exception_info.ExceptionPointers = &local_exception_pointers; + exception_info.ClientPointers = FALSE; + LARGE_INTEGER offset = { 0 }; + SetFilePointerEx(file_handle, offset, NULL, FILE_BEGIN); + SetEndOfFile(file_handle); + success = MiniDumpWriteDump(process_handle, ctx->crashed_pid, + file_handle, dump_type, &exception_info, NULL, NULL); + error = GetLastError(); + } + CloseHandle(process_handle); CloseHandle(file_handle); From 8dd13b77181c77c38f070382ab45e4678f1f03fc Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 27 Nov 2026 17:52:18 +0100 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index db47c23db6..1e493c96b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ **Fixes**: - Native: detect daemon startup failure to avoid a 10s stall in `sentry_init` on Windows and Linux. ([#2349](https://github.com/getsentry/sentry-native/pull/2349)) +- Native/Windows: fix minidump failures on CPUs with AMX enabled. ([#2353](https://github.com/getsentry/sentry-native/pull/2353)) ## 1.0.0-beta.2 From 62ebb5a902e9c4146a512fb9d82645d266649a0e Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 27 Nov 2026 19:10:08 +0100 Subject: [PATCH 3/3] fix(native): cast the XSTATE mask to DWORD CONTEXT_XSTATE and CONTEXT_CONTROL are signed long constants, which fails the ClangCL build with -Wsign-conversion. --- src/backends/native/minidump/sentry_minidump_windows.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backends/native/minidump/sentry_minidump_windows.c b/src/backends/native/minidump/sentry_minidump_windows.c index 20bc02e845..a0815ad145 100644 --- a/src/backends/native/minidump/sentry_minidump_windows.c +++ b/src/backends/native/minidump/sentry_minidump_windows.c @@ -108,7 +108,7 @@ sentry__write_minidump( # ifdef CONTEXT_XSTATE // Only sizeof(CONTEXT) is copied, without the extended state. Clear its // flag but keep the architecture bit that CONTEXT_XSTATE includes. - local_context.ContextFlags &= ~(CONTEXT_XSTATE & ~CONTEXT_CONTROL); + local_context.ContextFlags &= ~(DWORD)(CONTEXT_XSTATE & ~CONTEXT_CONTROL); # endif local_exception_pointers.ExceptionRecord = &local_exception_record; local_exception_pointers.ContextRecord = &local_context;