Bug 27954

Summary: Exception handling info garbled on x86_64-w64-mingw32
Product: binutils Reporter: Dominik Strasser <dominik_strasser>
Component: ldAssignee: Not yet assigned to anyone <unassigned>
Status: UNCONFIRMED ---    
Severity: normal    
Priority: P2    
Version: 2.35   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Dominik Strasser 2021-06-04 08:40:44 UTC
I am having a long standing issue with exception handling on x86_64-w64-mingw32.

The symptom is that I am getting a crash in ntdll!RtlUnwindEx when unwinding the stack between a thrown assertion and the catch handler.

I am suspecting an issue in binutils(ld) because the crash vanishes when I bind a different program with the identical objects.

I ran my program through wine which gives some additional information, namely an illegal EH information:
020c:fixme:seh:RtlVirtualUnwind unknown unwind info version 4 at 00000000080E350C
020c:fixme:seh:dump_unwind_info **** func 4cc6d40-4cc712f
020c:fixme:seh:dump_unwind_info unwind info at 00000000080E350C flags 0 prolog 0xd0 bytes function 00000000050C6D40-00000000050C712F
020c:fixme:seh:dump_unwind_info     0x1: PUSH_MACHFRAME 0
020c:fixme:seh:dump_unwind_info     0x6: pushq %rax
020c:fixme:seh:dump_unwind_info CHANIN 0

According to all documentation I found, only version 1 and 2 are legal values.
Additionally wine prints:
020c:fixme:seh:PUSH_MACHFRAME is not the last opcode.

I cannot provide an example as a lot of source code is involved, but I can compile binutils myself, and do any experiment you like.
Comment 1 Dominik Strasser 2021-06-04 08:55:07 UTC
I am chasing this bug for years, over several compiler and binutils versions. What would be helpful as a start would be some utility to dump the EH info structures from the .o file(s) and the executable. Does such an utility exist ?