[ros-dev] Patch for review: exception handling

Ge van Geldorp gvg at reactos.org
Sun Dec 18 22:15:54 CET 2005


The program below (when compiled with MSVC6, multithreaded DLL runtime) only
prints "in first handler" on ReactOS and then gets into an endless exception
loop:

int
main(int argc, char *argv[])
  {
  __try
    {
    RaiseException(0x55aa, 0, 0, NULL);
    }
  __except(EXCEPTION_EXECUTE_HANDLER)
    {
    printf("in first handler\n");
    }

  __try
    {
    RaiseException(0xaacc, 0, 0, NULL);
    }
  __except(EXCEPTION_EXECUTE_HANDLER)
    {
    printf("in second handler\n");
    }

  return 0;
  }

I believe the reason is that our RtlUnwind removes the target exception
frame too, which it shouldn't do. The following patch seems to solve the
issue:

Index: lib/rtl/i386/exception.c
===================================================================
--- lib/rtl/i386/exception.c	(revision 20225)
+++ lib/rtl/i386/exception.c	(working copy)
@@ -333,7 +333,10 @@
             RegistrationFrame2 = RegistrationFrame2->Next;
 
             /* Remove this handler */
-            RtlpSetExceptionList(OldFrame);
+            if (RegistrationFrame2 != RegistrationFrame)
+            {
+                RtlpSetExceptionList(OldFrame);
+            }
         }
     }
 
but I'm no expert on exception issues. Is this indeed the correct fix?

GvG



More information about the Ros-dev mailing list