https://bugs.winehq.org/show_bug.cgi?id=49698
--- Comment #2 from Martin Storsjö martin@martin.st --- (In reply to Paul Gofman from comment #1)
Thanks for bringing in handy test case.
I've tested the test.
The regression was triggered solely by ntdll switch to PE and does not interfere with any other patches.
The problem is in dlls/ntdll/signal_x86_64.c:call_consolidate_callback() function. It is supposed to return to the caller (RtlSetThreadContext) in case of normal return but in case if the callback unwinds (which is likely) the unwind should jump directly to the specified context and skip all the functions in between with their unwinds (that is the feature of consolidated unwind which does the unwind for multiple nested frames in one call). The required tricks were implemented with dwarf unwind info but not for PE unwinds, thus it was broken as soon as ntdll.dll is build as PE.
Patches [1], [2] are fixing the issue for me.
Awesome, thanks! Yeah I had a suspicion that call_consolidate_callback was the culprit here (but I hadn't dug deep enough to actually verify it).
My reason for poking into it actually was that I was looking into fixing unwinding for a PE based ntdll for arm64, but I didn't have any good clue for how to handle call_consolidate_callback without the DWARF tricks, so I wanted to look into how the x86_64 implementation worked in PE/SEH mode.
So - now I can try to do something similar to that with the ARM64 variant of SEH. :-)