views:

896

answers:

4

I have a vb.net project which sometimes, when running in the IDE, suddenly hangs. Normally this wouldn't be a problem. Just hit 'pause', look at the currently running threads, and find the deadlock (or whatever else).

But now I'm running into a situation where not only does the program hang, but trying to pause it causes visual studio itself to hang. In order to get control back, I have to kill the program-being-debugged's process, at which point visual studio comes back to life and says it was unable to pause execution. This is frustrating, because killing the process means the program state is lost (of course), so I don't know where the hang is.

So are there any common causes for this behavior? What should I be looking for?

A: 

I'd check the code of the program being debugged, I'm thinking there may be an infinite loop or race condition in the code you're trying to debug. This has been the case for me in the past, especially on a single-core laptop I used to have. Can you give any information about where in the program you think execution is when you try to pause?

Sukasa
Well I'm using a sortof message-passing paradigm. Each 'complicated to lock correctly' class has a call-queue which other classes must use to ask it to do anything.The program is a small game server. When it locks, there are multiple sockets queuing data-received onto a processing object, which queues displaying some logging info to the UI and also writes data back out to the sockets.That's what confuses me: it shouldn't be blocking the UI, because I try to avoid holding locks. It's not like I get an infinite queue loop either, because my cpu doesn't spike.
Strilanc
A: 

Check hotfixes and service packs. I've seen a bug related to .net programming and debugging hangs. (VS hangs for me when debugging C++ 32-bit apps on 64-bit os:es sometimes.)

Marcus Lindblom
+1  A: 

Finding a specific fix for a Visual Studio problem can be tricky: http://social.msdn.microsoft.com/Search/en-US/?query=visual%20studio%202008%20hang&ac=3

Additionally, not all hotfixes from Microsoft get released directly to the public. Some are only given out to customers whose systems are exhibiting a specific problem. So you have to contact Microsoft to the get the fix. They do this to limit the potential downside of releasing a hotfix that may break something else. So if all else fails, give them a call.

Here are some other things that I like to do when Visual Studio starts acting up:

  1. Delete old breakpoints and watch variables.
  2. With visual studio not running, delete the intellisense file (.ncb)
  3. Clean the solution and then do a rebuild of all of the code.
onedozenbagels
A: 

if your program installs global hooks (which communicate with app) - this might be the case. A hook tries to communicate with your app (which is paused by debugger) and gets locked. And debugger is unable to receive its window messages: classic deadlock between hooked debugger (with hook dll) and a hooking app.

Andrey