[PATCH] vcruntime140_1: Handle rethrowing from nested try blocks on x64.
Paul Gofman
pgofman at codeweavers.com
Tue Sep 8 15:36:41 CDT 2020
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
Here is MSVC test program I made for testing it: https://gist.github.com/gofman/a7cc10c4b815f3d35396d669901d37ad
dlls/vcruntime140_1/except_x86_64.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/dlls/vcruntime140_1/except_x86_64.c b/dlls/vcruntime140_1/except_x86_64.c
index 0e27b02db13..f66ae43721f 100644
--- a/dlls/vcruntime140_1/except_x86_64.c
+++ b/dlls/vcruntime140_1/except_x86_64.c
@@ -103,6 +103,7 @@ typedef struct
BOOL rethrow;
INT search_state;
INT unwind_state;
+ EXCEPTION_RECORD *prev_rec;
} cxx_catch_ctx;
typedef struct
@@ -473,7 +474,7 @@ static LONG CALLBACK cxx_rethrow_filter(PEXCEPTION_POINTERS eptrs, void *c)
FlsSetValue(fls_index, (void*)(DWORD_PTR)ctx->search_state);
if (rec->ExceptionCode != CXX_EXCEPTION)
return EXCEPTION_CONTINUE_SEARCH;
- if (rec->ExceptionInformation[1] == ((EXCEPTION_RECORD*)*__current_exception())->ExceptionInformation[1])
+ if (rec->ExceptionInformation[1] == ctx->prev_rec->ExceptionInformation[1])
ctx->rethrow = TRUE;
return EXCEPTION_CONTINUE_SEARCH;
}
@@ -503,6 +504,7 @@ static void* WINAPI call_catch_block4(EXCEPTION_RECORD *rec)
__CxxRegisterExceptionObject(&ep, &ctx.frame_info);
ctx.search_state = rec->ExceptionInformation[2];
ctx.unwind_state = rec->ExceptionInformation[3];
+ ctx.prev_rec = prev_rec;
(*__processing_throw())--;
__TRY
{
@@ -685,6 +687,12 @@ static DWORD cxx_frame_handler4(EXCEPTION_RECORD *rec, ULONG64 frame,
if (rec->ExceptionCode == CXX_EXCEPTION)
{
+ if (!rec->ExceptionInformation[1] && !rec->ExceptionInformation[2])
+ {
+ TRACE("rethrow detected.\n");
+ *rec = *(EXCEPTION_RECORD*)*__current_exception();
+ }
+
exc_type = (cxx_exception_type *)rec->ExceptionInformation[2];
if (TRACE_ON(seh))
--
2.26.2
More information about the wine-devel
mailing list