Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8310228

Improve error reporting for uncaught native exceptions on Windows

    XMLWordPrintable

Details

    • b17
    • windows

    Backports

      Description

        Currently, when an exception is thrown from native code called from Java, such as:

        const DWORD EX_CODE = 42;

        __declspec(dllexport) void throw_C_exception() {
            RaiseException(EX_CODE, EXCEPTION_NONCONTINUABLE, 0, NULL);
        }

        The stack is unwound until we get back to Java frames, at which point topLevelExceptionFilter in os_windows.cpp is invoked (which acts as the exception handler for the entire code cache).

        Since we have no explicit handling for this exception code, we eventually end up in Handle_FLT_Exception which checks if MxCsr is modified, restores it, and then returns EXCEPTION_CONTINUE_EXECUTION. However, this is done without making sure that the exception code corresponds to an FLT* exception.

        As a result, we end up entering topLevelExceptionFilter over and over, until the process finally abruptly terminates due to a stack overflow error.

        We should more carefully try to filter for FLT* exception codes in Handle_FLT_Exception, so that unrecognized exceptions are handled through the default VM error reporting mechanism.

        Attachments

          Issue Links

            Activity

              People

                jvernee Jorn Vernee
                jvernee Jorn Vernee
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: