Search code examples
.netwindbg

Why can't Windbg's SOS extension give me Syncblock data?


I'm using the Windbg GUI to try to troubleshoot an error in a WPF application, which is self-contained with dotnet SDK 8.0.108

If I run "!syncblk", I get this error message:

Error requesting SyncBlk data

Can anyone help me troubleshoot this error message? Why can't it get the syncblk data?

As requested, I've created a minimum reproducible example here

Steps to reproduce:

  • Clone that repo
  • Run the console project - it will create a dump file on the desktop
  • Run the wpf project, and click the button - it will create a second dump file on the desktop
  • Open the first dump file (from the console project), and type "!syncblk" command - it should work
  • Open the second dump file (from the wpf project), and type "!syncblk" command - it should give the error message "Error requesting SyncBlk data".

I'll be interested to hear if anyone else can verify this same repro, or if it's specific to my machine somehow.

I'm using WinDbg 1.2407.24003.0, with the default SOS extension.


Solution

  • You are creating the crash dump yourself using DiagnosticsClient.

    In your code you have

    var dumpType = DumpType.Normal;
    // var dumpType = DumpType.WithHeap;
    

    SyncBlocks are stored along with the objects on the heap. Besides the object data, there's also the method table (MT) in front of the object and the syncblock in front of the method table. As explained in a MS article.

    In order to analyze sync blocks, you need the heap, because the information is only there. The solution is in the commented line of code: store the crash dump with heap information.

    Why DumpType.WithHeap fails with HRESULT 0x80004005 (E_FAIL) - I have no idea. I switched to DumpType.Full and could successfully run !syncblk:

    0:000> !syncblk
    Index         SyncBlock MonitorHeld Recursion Owning Thread Info          SyncBlock Owner
    -----------------------------
    Total           80
    CCW             5
    RCW             10
    ComClassFactory 0
    Free            0