From 5e418f0ccfa307af3a6adbebfdedf01093f99ab8 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Fri, 25 May 2012 19:42:51 +0200 Subject: [PATCH] msvcrt: Handle rethrown exception in cxx_frame_handler. --- dlls/msvcrt/except_i386.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/dlls/msvcrt/except_i386.c b/dlls/msvcrt/except_i386.c index d8b03a4518c..7c3265cdaf3 100644 --- a/dlls/msvcrt/except_i386.c +++ b/dlls/msvcrt/except_i386.c @@ -373,7 +373,9 @@ static DWORD catch_function_nested_handler( EXCEPTION_RECORD *rec, EXCEPTION_REG if(rec->ExceptionCode == CXX_EXCEPTION) { PEXCEPTION_RECORD prev_rec = nested_frame->rec; - if(rec->ExceptionInformation[1] == 0 && rec->ExceptionInformation[2] == 0) + if((rec->ExceptionInformation[1] == 0 && rec->ExceptionInformation[2] == 0) || + (rec->ExceptionInformation[1] == prev_rec->ExceptionInformation[1] && + rec->ExceptionInformation[2] == prev_rec->ExceptionInformation[2])) { /* exception was rethrown */ rec->ExceptionInformation[1] = prev_rec->ExceptionInformation[1]; @@ -381,6 +383,13 @@ static DWORD catch_function_nested_handler( EXCEPTION_RECORD *rec, EXCEPTION_REG TRACE("detect rethrow: re-propagate: obj: %lx, type: %lx\n", rec->ExceptionInformation[1], rec->ExceptionInformation[2]); } + else if (nested_frame->prev_rec && + nested_frame->prev_rec->ExceptionInformation[1] == prev_rec->ExceptionInformation[1] && + nested_frame->prev_rec->ExceptionInformation[2] == prev_rec->ExceptionInformation[2]) + { + TRACE("detect threw new exception in catch block - not owning old(obj: %lx type: %lx)\n", + prev_rec->ExceptionInformation[1], prev_rec->ExceptionInformation[2]); + } else { /* new exception in exception handler, destroy old */ void *object = (void*)prev_rec->ExceptionInformation[1]; @@ -506,6 +515,15 @@ DWORD CDECL cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame if(rec->ExceptionCode == CXX_EXCEPTION) { + if (rec->ExceptionInformation[1] == 0 && rec->ExceptionInformation[2] == 0) + { + EXCEPTION_RECORD *exc_record = msvcrt_get_thread_data()->exc_record; + rec->ExceptionInformation[1] = exc_record->ExceptionInformation[1]; + rec->ExceptionInformation[2] = exc_record->ExceptionInformation[2]; + TRACE("detect rethrow: obj: %lx, type: %lx\n", + rec->ExceptionInformation[1], rec->ExceptionInformation[2]); + } + exc_type = (cxx_exception_type *)rec->ExceptionInformation[2]; if (rec->ExceptionInformation[0] > CXX_FRAME_MAGIC_VC8 &&