From d56ff67896a61eac267493429b1544a4e8738bfe Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Wed, 16 Jul 2025 20:57:37 +0200 Subject: [PATCH] Win: Add some context to access violations The Windows exception record is well documented [1] but it's not the easiest information to remember. Every time i see a crash log i still have to manually pull up the docs to check if the first argument being 0 means read or write. This PR adds this trivial information to our crash log, so I don't have to look it up any more. [1] https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-exception_record Pull Request: https://projects.blender.org/blender/blender/pulls/142109 --- source/blender/blenlib/intern/system_win32.cc | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/source/blender/blenlib/intern/system_win32.cc b/source/blender/blenlib/intern/system_win32.cc index 12b0650973e..98ed6e1000c 100644 --- a/source/blender/blenlib/intern/system_win32.cc +++ b/source/blender/blenlib/intern/system_win32.cc @@ -129,8 +129,34 @@ static void bli_windows_system_backtrace_exception_record(FILE *fp, PEXCEPTION_R fprintf(fp, "Exception Module : %s\n", module); fprintf(fp, "Exception Flags : 0x%.8x\n", record->ExceptionFlags); fprintf(fp, "Exception Parameters : 0x%x\n", record->NumberParameters); - for (DWORD idx = 0; idx < record->NumberParameters; idx++) { - fprintf(fp, "\tParameters[%d] : 0x%p\n", idx, (LPVOID *)record->ExceptionInformation[idx]); + + /* Special handling for access violations to make them a little easier to read. */ + if (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION && record->NumberParameters == 2) { + const char *action; + switch (record->ExceptionInformation[0]) { + case 0: + action = "read"; + break; + case 1: + action = "write"; + break; + case 8: + action = "execute"; + break; + default: + action = "unknown"; + break; + } + fprintf(fp, + "\tParameters[0] (action) : 0x%p (%s)\n", + (LPVOID *)record->ExceptionInformation[0], + action); + fprintf(fp, "\tParameters[1] (address) : 0x%p\n", (LPVOID *)record->ExceptionInformation[1]); + } + else { + for (DWORD idx = 0; idx < record->NumberParameters; idx++) { + fprintf(fp, "\tParameters[%d] : 0x%p\n", idx, (LPVOID *)record->ExceptionInformation[idx]); + } } if (record->ExceptionRecord) { fprintf(fp, "Nested ");