Over a million developers have joined DZone.

Sync Block Diagnostics with PSSCor2 (or PSSCor4)


Alternative title: yet another another another way to determine the sync object for which your thread is waiting. I should make a series out of these posts, as there are at least four distinct approaches now.

In case you haven’t seen them, PSSCor2 and PSSCor4 are WinDbg extensions that augment and extend SOS functionality for .NET 2.0 and 4.0 applications, respectively. They don’t ship with the .NET Framework (unlike SOS), but you can find them online.

To the case in point, PSSCor2/4 provides a command called !SyncBlk (akin to SOS’s command with the same name), which outputs the list of threads waiting for each of the locked sync blocks in your program. This is a one-stop shop for all Monitor-related deadlock and wait chain diagnostics, out of the box.

Here’s an example from a 64-bit app (the command output was edited to fit the screen):

0:011> .load C:\…\psscor2\amd64\psscor2 
0:011> !syncblk 
Index  Owning Thread Info 
   18  00000000007f2e40  1da8   0    
         Waiting threads: 4 
   19  000000001bbe14a0  185c   4    
         Waiting threads: 0 

The output immediately shows the locked sync blocks as well as the threads that are blocked waiting for them. Owning thread information provides the deadlocked wait chain immediately:

Thread 0 –> Sync Block 19 –> Thread 4 –> Sync Block 18 –> Thread 0


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}