Piotr Caban : msvcrt: Handle rethrown exception in cxx_frame_handler.

Alexandre Julliard julliard at winehq.org
Wed May 30 13:18:52 CDT 2012


Module: wine
Branch: master
Commit: 5e418f0ccfa307af3a6adbebfdedf01093f99ab8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5e418f0ccfa307af3a6adbebfdedf01093f99ab8

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri May 25 19:42:51 2012 +0200

msvcrt: Handle rethrown exception in cxx_frame_handler.

---

 dlls/msvcrt/except_i386.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/dlls/msvcrt/except_i386.c b/dlls/msvcrt/except_i386.c
index d8b03a4..7c3265c 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 &&




More information about the wine-cvs mailing list