Friday, March 04, 2011

Problems running sos-commands

Yesterday I tried opening up a standard dump file from a 64-bit Windows 2008 Server. It opened up just fine in windbg, but when I tried executing a command I got the following:

0:000> !dumpheap -stat

The garbage collector data structures are not in a valid state for traversal. It is either in the "plan phase," where objects are being moved around, or we are at the initialization or shutdown of the gc heap. Commands related to  displaying, finding or traversing objects as well as gc heap segments may not
work properly. !dumpheap and !verifyheap may incorrectly complain of heap  consistency errors.


Error requesting GC Heap data
Unable to build snapshot of the garbage collector state

This can happen if both the .NET 4.0 and the .NET 2.0 runtime are loaded in the same process. I actually tried using .loadby on both Framework versions and neither of them returned with an error

0:000> .loadby sos mscorwks
0:000> .loadby sos clr

The easiest way to resolve this is to run the following command:

0:000> .cordll -I mscorwks.dll -N -ve

Read more: Speaking of which...