From 6953d781cd0cf2e0c3afd98c443d30b2d62c0c5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20Karla=C5=A1?= Date: Sat, 17 Jan 2015 16:14:52 +0100 Subject: [PATCH] [sdb] Fix deadlock in case of runtime disconnect while fetching frames(Bug 24434) --- mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs | 4 ++++ mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs index 5350491dc0b..5499fef1cf6 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs @@ -1216,6 +1216,8 @@ namespace Mono.Debugger.Soft bool disconnected; + internal ManualResetEvent DisconnectedEvent = new ManualResetEvent (false); + void receiver_thread_main () { while (!closed) { try { @@ -1232,6 +1234,7 @@ namespace Mono.Debugger.Soft lock (reply_packets_monitor) { disconnected = true; + DisconnectedEvent.Set (); Monitor.PulseAll (reply_packets_monitor); TransportClose (); } @@ -2475,6 +2478,7 @@ namespace Mono.Debugger.Soft { closed = true; disconnected = true; + DisconnectedEvent.Set (); TransportClose (); } } diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs index 541118d66d6..5dbe5eb1fb5 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs @@ -22,7 +22,9 @@ namespace Mono.Debugger.Soft public StackFrame[] GetFrames () { FetchFrames (true); - fetchingEvent.WaitOne (); + if (WaitHandle.WaitAny (new []{ vm.conn.DisconnectedEvent, fetchingEvent }) == 0) { + throw new VMDisconnectedException (); + } return frames; } -- 2.11.4.GIT