Search code examples
.netwindbgdeadlockreaderwriterlock

How do I find the lockholder (reader) of my ReaderWriterLock in windbg


I've got a dump of a .Net process that has hung due to a deadlock (the gui thread is no longer responding, and my logs show that some threads have stopped responding). I have taken a snapshot and am now looking through it in windbg, and all threads bar one are waiting for the last one. Looking at that one thread's stacktrace with !clrstack -p I can see that it is trying to aquire a write on a ReaderWriterLock

How do I tell which other thread holds that lock so I can start figuring out how the deadlock happened?

thanks

[edit] apparently there was a command !rwlocks in the .Net1.1 sos.dll to help with this, but it isn't there in the .Net2.0 version. The hunt continues


Solution

  • So far the best approach is to look at the !dso for all thread stacks, and see which ones reference the lock. A quick check after that has alles us to track down which threads hold locks. Really not a pretty or quick way though...