Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 9b67631

Browse files
committed
Debugger: During callback processing, handle the COMException "Process was terminated. (Exception from HRESULT: 0x80131301)".
The exception occurs if a process is killed (e.g. console window of console application closed) while the application is doing something involving debugger callbacks (Debug.WriteLine calls, or throwing+handling exceptions).
1 parent b48164d commit 9b67631

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

src/AddIns/Debugger/Debugger.Core/Process.cs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.Collections.Generic;
2121
using System.Linq;
2222

23+
using System.Runtime.InteropServices;
2324
using ICSharpCode.NRefactory.TypeSystem;
2425
using Debugger.Interop.CorDebug;
2526
using Debugger.Interop.CorSym;
@@ -480,17 +481,26 @@ internal void AsyncContinue(DebuggeeStateAction action, Thread threadToRun = nul
480481
{
481482
AssertPaused();
482483

483-
if (threadToRun != null) {
484-
corProcess.SetAllThreadsDebugState(CorDebugThreadState.THREAD_SUSPEND, null);
485-
threadToRun.CorThread.SetDebugState(CorDebugThreadState.THREAD_RUN);
486-
} else {
487-
corProcess.SetAllThreadsDebugState(CorDebugThreadState.THREAD_RUN, null);
488-
}
489-
490-
NotifyResumed(action);
491-
corProcess.Continue(0);
492-
// this.TraceMessage("Continue");
484+
try {
485+
if (threadToRun != null) {
486+
corProcess.SetAllThreadsDebugState(CorDebugThreadState.THREAD_SUSPEND, null);
487+
threadToRun.CorThread.SetDebugState(CorDebugThreadState.THREAD_RUN);
488+
} else {
489+
corProcess.SetAllThreadsDebugState(CorDebugThreadState.THREAD_RUN, null);
490+
}
493491

492+
NotifyResumed(action);
493+
corProcess.Continue(0);
494+
// this.TraceMessage("Continue");
495+
} catch (COMException ex) {
496+
if (ex.HResult == unchecked((int)0x80131301)) {
497+
// Process was terminated. (Exception from HRESULT: 0x80131301)
498+
// This occurs if a process is killed (e.g. console window of console application closed)
499+
// while the application is doing something involving debugger callbacks (Debug.WriteLine calls, or throwing+handling exceptions).
500+
501+
// I think we can safely ignore this error.
502+
}
503+
}
494504
if (action == DebuggeeStateAction.Clear) {
495505
OnResumed();
496506
}

0 commit comments

Comments
 (0)