Skip to content

Commit 13e87f4

Browse files
author
Zachary Turner
committedMay 16, 2017
[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 llvm-svn: 303219
1 parent 79eb3b0 commit 13e87f4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎llvm/lib/Support/CrashRecoveryContext.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ CrashRecoveryContext::unregisterCleanup(CrashRecoveryContextCleanup *cleanup) {
164164

165165
static LONG CALLBACK ExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo)
166166
{
167+
switch (ExceptionInfo->ExceptionRecord->ExceptionCode)
168+
{
169+
case DBG_PRINTEXCEPTION_C:
170+
case DBG_PRINTEXCEPTION_WIDE_C:
171+
case 0x406D1388: // set debugger thread name
172+
return EXCEPTION_CONTINUE_EXECUTION;
173+
}
174+
167175
// Lookup the current thread local recovery object.
168176
const CrashRecoveryContextImpl *CRCI = CurrentContext->get();
169177

0 commit comments

Comments
 (0)
Please sign in to comment.