Galya Bar
Galya Bar

Reputation: 66

Debugging a Deadlock with !dlk command returns unkown thread name

Im trying to debug a deadlock in my process by using the SOSEX command !dlk I get the following output:

*DEADLOCK DETECTED*

CLR thread 0xac holds the lock on SyncBlock 00000012ac132068 OBJ:00000012830d66a0[System.Object]
and is waiting for the lock on SyncBlock 00000012ae4ba6b8 OBJ:00000012808391f8[System.Collections.Generic.Dictionary`2[[System.Guid, mscorlib],[CaptureServices.GenericInfrastructure.Controlling.CapManager.MO.CallRecorder.ICallRecorder, Capture Manager]]]

CLR thread 0x9a holds the lock on SyncBlock 00000012ae4ba6b8 OBJ:00000012808391f8[System.Collections.Generic.Dictionary`2[[System.Guid, mscorlib],[CaptureServices.GenericInfrastructure.Controlling.CapManager.MO.CallRecorder.ICallRecorder, Capture Manager]]]
and is waiting for the lock on SyncBlock 00000012ac132068 OBJ:00000012830d66a0[System.Object]

I would like to be able to get the call stack of these threads, but I cant find the threads IDs (0xac, 0x9a) in the lists of threads. I tried the following commands, and the above threads are not listed in any of the results:

  1. ~ - should shows all threads (managed and unmanaged)
  2. ~*e!clrstack - should show the call stack of all threads
  3. ~*e!dumpstack - dump all managed threads

is there another way to see the call stack of the threads found in the deadlock that I might be missing? I even tried to convert the thread ID to decimal but failed to find a matching thread ID.

thanks

Upvotes: 1

Views: 448

Answers (1)

Galya Bar
Galya Bar

Reputation: 66

The following article helped me how to read the results of the !dlk command. according to the article, if for example we found a deadlock in thread 0xac:

CLR **thread 0xac** holds the lock on SyncBlock 00000012ac132068 OBJ:00000012830d66a0[System.Object]

The results of the !thread command have 3 "IDs" columns:

  1. logical thread ID (1st column)
  2. CLR ID (2nd column)
  3. OSID (3rd column)

The thread ID in !dlk is actually the CLR ID in the !thread results: (ac) = 172. CLR id 172 is thread 177.

0:000> !threads
                                                                                                        Lock  
       ID OSID ThreadOBJ           State GC Mode     GC Alloc Context                  Domain           Count Apt Exception
 177  172 1188 00000012abfcaee0  3029220 Preemptive  0000000000000000:0000000000000000 00000012f0e94d70 3     MTA (Threadpool Worker) 

now I could switch to thread 177 by command: ~177s

and see the thread's call stack by command: !clrstack

Upvotes: 1

Related Questions