Skip to content

Commit e3ed11b

Browse files
committed
Isolation of COMException in GetFrames(). Sometimes fetching frames may throw CORDBG_E_BAD_THREAD_STATE, and we should handle it. Otherwise the debugger event thread will be corrupted.
(cherry picked from commit 39d4670)
1 parent 700c3c6 commit e3ed11b

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

Mono.Debugging.Win32/CorDebuggerBacktrace.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Mono.Debugging.Client;
88
using Mono.Debugging.Evaluation;
99
using System.Linq;
10+
using System.Runtime.InteropServices;
1011

1112
namespace Mono.Debugging.Win32
1213
{
@@ -29,12 +30,27 @@ public CorBacktrace (CorThread thread, CorDebuggerSession session): base (sessio
2930

3031
internal static IEnumerable<CorFrame> GetFrames (CorThread thread)
3132
{
32-
foreach (CorChain chain in thread.Chains) {
33-
if (!chain.IsManaged)
34-
continue;
35-
foreach (CorFrame frame in chain.Frames)
36-
yield return frame;
33+
var corFrames = new List<CorFrame> ();
34+
try {
35+
foreach (CorChain chain in thread.Chains) {
36+
if (!chain.IsManaged)
37+
continue;
38+
try {
39+
var chainFrames = chain.Frames;
40+
41+
foreach (CorFrame frame in chainFrames)
42+
corFrames.Add (frame);
43+
}
44+
catch (COMException e) {
45+
DebuggerLoggingService.LogMessage ("Failed to enumerate frames of chain: {0}", e.Message);
46+
}
47+
}
48+
49+
}
50+
catch (COMException e) {
51+
DebuggerLoggingService.LogMessage ("Failed to enumerate chains of thread: {0}", e.Message);
3752
}
53+
return corFrames;
3854
}
3955

4056
internal List<CorFrame> FrameList {

0 commit comments

Comments
 (0)