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
This commit is contained in:
Ray Molenkamp
2025-07-16 20:57:37 +02:00
committed by Ray molenkamp
parent 63a3499674
commit d56ff67896

View File

@@ -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 ");