1

Resolved

Stop debugging before hitting any breakpoint gives error, VS hang

description

Do all the preliminaries to get your azure web site ready to be debugged.
In server explorer, debug attach (python).
Make sure you don't get any error for that.
Then go to Debug, Stop Debugging.

You'll get an error and after you dismiss it, VS will appear to hang (it's unresponsive for a while):
---------------------------
Microsoft Visual Studio
---------------------------
The debugger was unable to terminate one or more processes:



[21588] python.exe @ wss://hvbottlepolls2.azurewebsites.net:443/ptvsd: The debugger is still attaching to the process or the process is not currently executing the type of code selected for debugging.



The debugger may be unstable now. It is recommended that you save all files and exit.
---------------------------
OK   
---------------------------
Update: After waiting for some time, VS stops the debugging session and comes back to life.

Update 2: After coming back to life, it was probably in a bad state, like the error message said. Because I went to restart the web site in the portal, then refreshed the web page, and VS crashed. Exception from event log:
Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
Stack:
   at Microsoft.PythonTools.Debugger.DebugEngine.AD7Engine.Send(Microsoft.VisualStudio.Debugger.Interop.IDebugEvent2, System.String, Microsoft.VisualStudio.Debugger.Interop.IDebugProgram2, Microsoft.VisualStudio.Debugger.Interop.IDebugThread2)
   at Microsoft.PythonTools.Debugger.DebugEngine.AD7ProgramCreateEvent.Send(Microsoft.PythonTools.Debugger.DebugEngine.AD7Engine)
   at Microsoft.PythonTools.Debugger.DebugEngine.AD7Engine.SendLoadComplete(Microsoft.PythonTools.Debugger.DebugEngine.AD7Thread)
   at Microsoft.PythonTools.Debugger.DebugEngine.AD7Engine.OnProcessLoaded(System.Object, Microsoft.PythonTools.Debugger.ThreadEventArgs)
   at Microsoft.PythonTools.Debugger.PythonProcess.HandleProcessLoad(System.IO.Stream)
   at Microsoft.PythonTools.Debugger.PythonProcess.DebugEventThread()
   at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()

comments

pminaev wrote May 22 at 8:59 PM

I can repro this reliably. It seems that we don't get a "process start" debugger notification from the server until the first request is handled, probably because it's waiting on an HTTP request read from a pipe? So when you try to stop, debugger thinks that it hasn't successfully completed the attach yet.

pminaev wrote Jun 12 at 7:44 PM

Also, this happens with any kind of remote debugging, not just Azure.