c# - How do I debug a deadlock when only one thread shows up in Visual Studio? -
my application blocking indefinitely on call lock ( obj ), there no other threads in threads window have code browse @ all. isn't kind of necessary there thread involved? why isn't showing up, , cause of not showing up?
update: think figured out causing it. had sort of hackish block whereby wait() on manualresetevent inside 2 locks. problem needed release locks before waiting other threads use them, doing this:
lock ( 1 ) { lock ( 2 ) { ... monitor.exit( 2 ); monitor.exit( 1 ); syncevent.wait(); monitor.enter( 1 ); monitor.enter( 2 ); } } what wasn't counting on monitor.exit() decrements internal recursion counter, , possible method being called block synchronized; lock not being released.
i guess bad idea begin with. i've since moved call wait() outside of locked blocks , seems working fine now.
thanks insight.
although, think it, if method being called code synchronized on 1 of locks, still not released when call wait occurs. therefore i'll have careful never call synchronized block, guess.
there no other threads in threads window have code browse @ all
i assure other threads running code. whether have source code on machine or not doesn't matter threads.
isn't kind of necessary there thread involved?
yes.
why isn't showing up, , cause of not showing up?
perhaps thread took out lock has gone sleep. it's rude take lock , sleep without unlocking it, possible. or perhaps 1 of threads running code don't have source code took out lock. example, suppose finalizer thread took out lock while finalizing object, , finalizer thread finished current batch of work. again, rude , stupid lock object during finalization , not unlock it, possible.
there million possibilities; haven't given enough information more guess randomly. advice: build small repro demonstrates problem. in doing you'll either figure out problem yourself, or you'll have concrete can discuss rather making guesses in advance of facts.
Comments
Post a Comment