Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging a Deadlock with Windbg's !clrstack command

When I issued clrstack command, I got the following output. It is the callstack of a blocking thread which owns a deadlock and results in a deadlock. Is that its exact purpose? Does it have any other purposes (without any parameters). Where can I get more information?

!clrstack
OS Thread Id: 0x1b2c (6956)
ESP       EIP     
0012f370 7c90e514 [HelperMethodFrame: 0012f370] System.Threading.Thread.SleepInternal(Int32)
0012f3c4 79299275 System.Threading.Thread.Sleep(Int32)
0012f3c8 00e0030f testlock.LockTest.Test()
0012f420 00e00146 testlock.Program.Main(System.String[])
0012f69c 79e71b4c [GCFrame: 0012f69c] 
like image 832
Maanu Avatar asked Aug 21 '10 05:08

Maanu


1 Answers

Use sosex by Steve Johnson. This has a command to detect deadlocks for you.

Download the extension from the link and load it, eg

.load D:\sosex_32\sosex.dll

then issue

!dlk

example output (taken from steve's site)

0:010> !dlk Deadlock detected: CLR thread 4 holds sync block 00000000024c6970 OBJ:000000007fff0f80[System.String] STRVAL=SYNC1 waits sync block 00000000024c6928 OBJ:000000007fff0fa8[System.String] STRVAL=SYNC2 CLR thread 5 holds sync block 00000000024c6928 OBJ:000000007fff0fa8[System.String] STRVAL=SYNC2 waits sync block 00000000024c6970 OBJ:000000007fff0f80[System.String] STRVAL=SYNC1 CLR Thread 4 is waiting at ConsoleTestApp.ConsoleTestApp.MonitorDeadlockThreadProc()+0xa4(IL) [C:\dev\ConsoleTestApp\ConsoleTestApp.cs, line 195] CLR Thread 5 is waiting at ConsoleTestApp.ConsoleTestApp.MonitorDeadlockThreadProc()+0xa4(IL) [C:\dev\ConsoleTestApp\ConsoleTestApp.cs, line 195]

See also this link for a walkthrough

like image 172
wal Avatar answered Sep 27 '22 18:09

wal