[PATCH] D33260: [CrashRecovery] Don't treat OutputDebugString as a crash

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 14:42:10 PDT 2017


zturner created this revision.

After spending 2 days tracking down a bizarre silent program termination when using the SetupApi code path for locating the MSVC toolchain, we finally traced it down to this.  Internal to the SetupApi com library, someone is calling `OutputDebugString`, which raises an exception so that the debugger can handle.

Honestly, we probably should not be using `AddVectoredExceptionHandler` in the first place.  There are too many cases where `RaiseException` is used on purpose, and a library intends to catch it itself.  By using `AddVectoredExceptionHandler`, we break all of these applications.

Regardless, this makes things better right now, and perhaps in the future we can look into using `SetUnhandledExceptionFilter`.


https://reviews.llvm.org/D33260

Files:
  llvm/lib/Support/CrashRecoveryContext.cpp


Index: llvm/lib/Support/CrashRecoveryContext.cpp
===================================================================
--- llvm/lib/Support/CrashRecoveryContext.cpp
+++ llvm/lib/Support/CrashRecoveryContext.cpp
@@ -164,6 +164,9 @@
 
 static LONG CALLBACK ExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo)
 {
+  if (ExceptionInfo->ExceptionRecord->ExceptionCode == DBG_PRINTEXCEPTION_C)
+    return EXCEPTION_CONTINUE_EXECUTION;
+
   // Lookup the current thread local recovery object.
   const CrashRecoveryContextImpl *CRCI = CurrentContext->get();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33260.99206.patch
Type: text/x-patch
Size: 552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170516/14ab41be/attachment.bin>


More information about the llvm-commits mailing list