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.
From: Brendan Shanks bshanks@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))
This merge request was approved by Piotr Caban.