[llvm] r303219 - [Support] Ignore OutputDebugString exceptions in our crash recovery.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 15:50:32 PDT 2017


Author: zturner
Date: Tue May 16 17:50:32 2017
New Revision: 303219

URL: http://llvm.org/viewvc/llvm-project?rev=303219&view=rev
Log:
[Support] Ignore OutputDebugString exceptions in our crash recovery.

Since we use AddVectoredExceptionHandler, we get notified of
every exception that gets raised by a program.  Sometimes these
are not necessarily errors though, and this can be especially
true when linking against a library that we have no control
over, and may raise an exception internally which it intends
to catch.

In particular, the Windows API OutputDebugString does exactly
this.  It raises an exception inside of a __try / __except,
giving the debugger a chance to handle the exception to print
the message to the debug console.

But this doesn't interoperate nicely with our vectored exception
handler, which just sees another exception and decides that we
need to terminate the program.

Add a special case for this so that we ignore ODS exceptions
and continue normally.

Note that a better fix is to simply not use vectored exception
handlers and use SEH instead, but given that MinGW doesn't support
SEH, this is the only solution for MinGW.

Differential Revision: https://reviews.llvm.org/D33260

Modified:
    llvm/trunk/lib/Support/CrashRecoveryContext.cpp

Modified: llvm/trunk/lib/Support/CrashRecoveryContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CrashRecoveryContext.cpp?rev=303219&r1=303218&r2=303219&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CrashRecoveryContext.cpp (original)
+++ llvm/trunk/lib/Support/CrashRecoveryContext.cpp Tue May 16 17:50:32 2017
@@ -164,6 +164,14 @@ CrashRecoveryContext::unregisterCleanup(
 
 static LONG CALLBACK ExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo)
 {
+  switch (ExceptionInfo->ExceptionRecord->ExceptionCode)
+  {
+  case DBG_PRINTEXCEPTION_C:
+  case DBG_PRINTEXCEPTION_WIDE_C:
+  case 0x406D1388:  // set debugger thread name
+    return EXCEPTION_CONTINUE_EXECUTION;
+  }
+
   // Lookup the current thread local recovery object.
   const CrashRecoveryContextImpl *CRCI = CurrentContext->get();
 




More information about the llvm-commits mailing list