Uploaded image for project: 'Core ReactOS'
  1. Core ReactOS
  2. CORE-16746

MS SEH0026 broken with GCC

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • None
    • None

    Description

      Source for the test: https://github.com/microsoft/compiler-tests/blob/master/seh/seh0026.c

      The test uses 2 functions and multiple levels of SEH with finally handlers and one except handler. The reason is nested exception handling in combination with multiple nested SEH blocks using thhe same registration frame.

      • At the beginning the current state is saved using setjmp
      • The last try in the subfunction raises an exception
      • The exception handler locates the except block in the first function
      • Unwinding starts
      • Each invokation of a handler function is wrapped in SEH to catch nested exceptions
      • In the 2nd finally handler in the subfunction, longjmp is called
      • longjmp invokes RtlUnwind
      • Unwinding starts again
      • The unwind handler now hits the SEH frame that protects against nested exceptions, which copies the previous registration frame to the DispatcherContext and returns ExceptionNestedException
      • RtlUnwind now skips past the returned seh frame (in this case the frame was already removed during unwinding anyway)
      • Unwinding continues to the first function, and the last finally handler calls longjmp again
      • Again unwinding is initiated with RtlUnwind
      • Again the handler that protects the finally handler is invoked, returning the previous frame, that caused the unwind
      • RtlUnwind again skips this frame entirely, but this frame was still active, containing the final except block.
      • Unwinding completes without calling the except block at all

       

      With current MSVC versions all SEH blocks share one registration frame, so this is the same as with PSEH. The test succeeds on MSVC builds.

       

      TODO:

      • Debug how the whole thing works on MSVC builds
      • Fix it?

       

       

      Attachments

        Activity

          People

            ThePhysicist Timo Kreuzer
            ThePhysicist Timo Kreuzer
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: