Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 26 additions & 6 deletions src/backends/native/minidump/sentry_minidump_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 &= ~(DWORD)(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) {
Expand All @@ -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;
}
Expand All @@ -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);

Expand Down
Loading