-
-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pack MDEI struct to fix issue #4407 #4474
base: master
Are you sure you want to change the base?
Conversation
Additional Note: I haven't looked at the |
So it's technically not |
core/sys/windows/dbghelp.odin
Outdated
@@ -15,7 +15,7 @@ MINIDUMP_DIRECTORY :: struct { | |||
Location: MINIDUMP_LOCATION_DESCRIPTOR, | |||
} | |||
|
|||
MINIDUMP_EXCEPTION_INFORMATION :: struct { | |||
MINIDUMP_EXCEPTION_INFORMATION :: struct #packed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct #max_field_align(4)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, cool! I didn't know that was a directive!
This seems good but I don't know if I'm applying the directive right? I'm getting alignment errors after using it.
Below is the disassembly from Visual Studio
mdei: MINIDUMP_EXCEPTION_INFORMATION
00007FF74395AD64 movaps xmmword ptr [rsp+1E0h],xmm0
mdei.ThreadId = GetCurrentThreadId()
00007FF74395AD6C call GetCurrentThreadId (07FF74395B412h)
00007FF74395AD71 mov ecx,eax
00007FF74395AD73 mov rax,qword ptr [rsp+0B8h]
00007FF74395AD7B mov dword ptr [rsp+1E0h],ecx
mdei.ExceptionPointers = pException // pass in 'nil' would make MiniDumpWriteDump() return TRUE
00007FF74395AD82 mov qword ptr [rsp+1E8h],rax
mdei.ClientPointers = FALSE
00007FF74395AD8A mov dword ptr [rsp+1F0h],0
Below is the LLVM IR
%48 = getelementptr inbounds %sys_windows.MINIDUMP_EXCEPTION_INFORMATION, ptr %mdei, i32 0, i32 0, !dbg !341
%49 = call x86_stdcallcc i32 @GetCurrentThreadId(), !dbg !341
store i32 %49, ptr %48, align 4, !dbg !341
%50 = getelementptr inbounds %sys_windows.MINIDUMP_EXCEPTION_INFORMATION, ptr %mdei, i32 0, i32 1, !dbg !342
store ptr %0, ptr %50, align 8, !dbg !342
%51 = getelementptr inbounds %sys_windows.MINIDUMP_EXCEPTION_INFORMATION, ptr %mdei, i32 0, i32 2, !dbg !343
store i32 0, ptr %51, align 4, !dbg !343
This is the diff
diff --git a/core/sys/windows/dbghelp.odin b/core/sys/windows/dbghelp.odin
index 4bbad258d..e32b4c874 100644
--- a/core/sys/windows/dbghelp.odin
+++ b/core/sys/windows/dbghelp.odin
@@ -15,7 +15,7 @@ MINIDUMP_DIRECTORY :: struct {
Location: MINIDUMP_LOCATION_DESCRIPTOR,
}
-MINIDUMP_EXCEPTION_INFORMATION :: struct #packed {
+MINIDUMP_EXCEPTION_INFORMATION :: struct #max_field_align(4) {
ThreadId: DWORD,
ExceptionPointers: ^EXCEPTION_POINTERS,
ClientPointers: BOOL,
And here's the version to show I did update the compiler.
..\odin.exe version dev-2024-11:c4b273958
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
30fb668
to
716db2f
Compare
Now relies on #4611 |
716db2f
to
e5effd4
Compare
e5effd4
to
276dab6
Compare
MINIDUMP_EXCEPTION_INFORMATION
is expected to be packed (which is, of course, not documented byMSDN
) so this packs it so that it can be used inMinidumpWriteDump
.