Bug 57886 - Debugger blocks UI thread waiting for a response from the debuggee
Summary: Debugger blocks UI thread waiting for a response from the debuggee
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Debugger ()
Version: 4.6.0 (15.3)
Hardware: PC Windows
: Normal normal
Target Milestone: 15.5
Assignee: Joaquin Jares
URL:
Depends on:
Blocks:
 
Reported: 2017-06-30 16:11 UTC by Frank A. Krueger
Modified: 2017-08-09 13:40 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Image showing the UI call stack when blocked (629.21 KB, image/png)
2017-06-30 16:11 UTC, Frank A. Krueger
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description Frank A. Krueger 2017-06-30 16:11:37 UTC
Created attachment 23243 [details]
Image showing the UI call stack when blocked

When stopping the debugger with a breakpoint set, the debugger can "deadlock" (not really a deadlock because it can be relieved by disconnecting the debuggee) waiting for a response from the debuggee.

This doesn't happen normally if the debuggee responds as expected.

I don't see any reason why stopping the debugger should block the UI. This work should be done on a background thread so that if you do get a bad debug connection, it won't lock the IDE.

If the work must absolutely be done on the UI thread, then timeouts should be used on these blocking operations.

---

Repro:

1. Start Debugging
2. Pause on a breakpoint
3. Hit Stop
4. Note that get_Breakpoints, which waits on a lock, is executing on the main thread.

Under normal circumstances: everything is fine and the debuggeee responded immediately freeing the UI thread
Under other circumstances: the UI thread can block indefinitely waiting for a response from the debuggee

---

The contention seems to be over the `slock` field of DebuggerSession. The `TargetExited` event is sent while also trying to remove breakpoints. However, because the target has exited it cannot release breakpoints (it's exited). This locks the actions needed by the TargetExited event waiting for a response about the breakpoints.

---

I have attached an image of the stack trace of the UI thread when one of these deadlocks occurs.