Skip to content

fix(native/breakpad): capture abort() on Windows#1708

Open
jpnurmi wants to merge 5 commits intomasterfrom
jpnurmi/feat/native-abort
Open

fix(native/breakpad): capture abort() on Windows#1708
jpnurmi wants to merge 5 commits intomasterfrom
jpnurmi/feat/native-abort

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented May 8, 2026

The handler was directly copied from inproc (#1446):

static void
handle_sigabrt(int signum)
{
(void)signum;
// Capture the current CPU context
CONTEXT context;
RtlCaptureContext(&context);
// Create a synthetic exception record for abort
EXCEPTION_RECORD record;
memset(&record, 0, sizeof(record));
record.ExceptionCode = STATUS_FATAL_APP_EXIT;
record.ExceptionFlags = EXCEPTION_NONCONTINUABLE;
# if defined(_M_AMD64)
record.ExceptionAddress = (PVOID)context.Rip;
# elif defined(_M_IX86)
record.ExceptionAddress = (PVOID)context.Eip;
# elif defined(_M_ARM64)
record.ExceptionAddress = (PVOID)context.Pc;
# endif
EXCEPTION_POINTERS exception_pointers;
exception_pointers.ContextRecord = &context;
exception_pointers.ExceptionRecord = &record;
handle_exception(&exception_pointers);
// If we get here, call the previous handler or terminate
if (g_previous_sigabrt_handler && g_previous_sigabrt_handler != SIG_DFL
&& g_previous_sigabrt_handler != SIG_IGN) {
g_previous_sigabrt_handler(signum);
}
// Terminate the process - abort() must not return
TerminateProcess(GetCurrentProcess(), 3);
}

Example event: https://sentry-sdks.sentry.io/issues/7467638795

Close: #591

@jpnurmi
Copy link
Copy Markdown
Collaborator Author

jpnurmi commented May 8, 2026

A) Do we care to share the handler code somewhere?
B) Is it a feature, or rather a fix? 😅

@supervacuus
Copy link
Copy Markdown
Collaborator

A) Do we care to share the handler code somewhere?

I don't think this is a high-value module for reuse or downstream maintenance. Maybe one could even argue that keeping implementations separate allows the backends to add backend-specific context that should be distinct with the underlying UEF implementation.

B) Is it a feature, or rather a fix? 😅

I would call it a fix, but I don't think it matters much.

@jpnurmi jpnurmi changed the title feat(native): capture abort() on Windows fix(native/breakpad): capture abort() on Windows May 8, 2026
@jpnurmi
Copy link
Copy Markdown
Collaborator Author

jpnurmi commented May 8, 2026

I don't think this is a high-value module for reuse or downstream maintenance. Maybe one could even argue that keeping implementations separate allows the backends to add backend-specific context that should be distinct with the underlying UEF implementation.

I ended up with a shared helper after all, because including <signal.h> conflicts with breakpad's definitions:
https://github.com/getsentry/breakpad/blob/47d70322c848012ed801e36841767d7ffb79412d/src/google_breakpad/common/minidump_exception_linux.h#L52

Comment thread src/sentry_os.c
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.

Alternative backends on Windows don't catch crashes caused by abort()

2 participants