[PATCH 0/1] MR2685: msvcrt: Fix crash when rethrowing after a non-C++ exception on x86_64.
This fixes a crash seen with the .NET Framework 3.5 SP1 installer in a 64-bit prefix where `ServiceModelReg.exe` throws a C++ exception, it's rethrown again, then a CLR exception (`0xe0434f4d`) exception is thrown, and finally there's another C++ rethrow. At the last rethrow, `cxx_frame_handler()` detects the rethrow and sets `*rec` to the previous exception record, which is the CLR exception, not the C++ exception. If `+seh` is enabled, it then assumes `*rec` is a C++ exception and tries to TRACE info about it, which crashes. Move the rethrow detection before the exception type check, so the TRACEs are not done. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2685
From: Brendan Shanks <bshanks(a)codeweavers.com> --- dlls/msvcrt/except_x86_64.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dlls/msvcrt/except_x86_64.c b/dlls/msvcrt/except_x86_64.c index d40b9985cd2..b07a7b83772 100644 --- a/dlls/msvcrt/except_x86_64.c +++ b/dlls/msvcrt/except_x86_64.c @@ -579,14 +579,14 @@ static DWORD cxx_frame_handler(EXCEPTION_RECORD *rec, ULONG64 frame, return ExceptionContinueSearch; } + if (rec->ExceptionCode == CXX_EXCEPTION && + (!rec->ExceptionInformation[1] && !rec->ExceptionInformation[2])) + { + TRACE("rethrow detected.\n"); + *rec = *msvcrt_get_thread_data()->exc_record; + } if (rec->ExceptionCode == CXX_EXCEPTION) { - if (!rec->ExceptionInformation[1] && !rec->ExceptionInformation[2]) - { - TRACE("rethrow detected.\n"); - *rec = *msvcrt_get_thread_data()->exc_record; - } - exc_type = (cxx_exception_type *)rec->ExceptionInformation[2]; if (TRACE_ON(seh)) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2685
This merge request was approved by Piotr Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2685
participants (3)
-
Brendan Shanks -
Brendan Shanks (@bshanks) -
Piotr Caban (@piotr)