-->

Sunday, November 3, 2013

Debugging C# crash at a customer site

A debug session with a customer

We have an instance of crash going on at the customer. Here is an account of what happens in a typical debugging of customer session.

Preparation


We have a call the next day. Although I have used windbg before, I don't have a lot of experience with managed code debugging so I am writing this as I prepare for this. The crash dump that the customer has sent us from the production machine does not load up properly on my machine. We only have a few hours with the customer and we need to figure out what is going on. We need to prepare for it so that we can do the best in the amount of time we get with the customer.

Let us debug a simple console app written in C# using the windbg sos.dll extension.
 
 class Program
    {
        static void Main(string[] args)
        {
            System.Console.WriteLine("THIS IS COOL");
            runme();
        }
       
        static  void runme()
        {
            while (true)
            {
                int num;
                var x = System.Console.ReadLine();
                Int32.TryParse(x, out num);
                if (num == 100)
                {
                    string crashStr = null;
                    crashStr.Clone();

                }
            }
        }
    }

Run this program and make sure the target is x86 since we will debug using x86.  Some history to remember:

"""
For .NET framework 1.1 the SOS extension has all the information about .NET internals ‘baked-in’ itself (some of those information you would normally expect to be in the symbol files) – so all you needed was loading the SOS. From the .NET version 2.0 the definition of data structures was separated into separate binary – mscordacwks (sometimes called data access layer). When loading the SOS extension it will need to also load correct data access layer (for correct architecture and version of .NET framework targeted by the debugged application/dump). Another important change for our purposes was introduced in .NET framework 4.0 – the mscorwks.dll module was replaced with module clr.dll. I’ll show how all those facts affects the managed code debugging.
"""

For our purposes, we will use .net framework 2.0 on x86 .

I run the following commands:

0:005> .cordll -ve -u -l
CLRDLL: Loaded DLL C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscordacwks.dll
CLR DLL status: Loaded DLL C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscordacwks.dll
0:005> .loadby sos.dll mscorwks
Unable to find module 'mscorwks'
0:005> .loadby sos.dll clr

Oh, mistake, my crash dump is at .net 2.0. So I recompile my test program to target .net version 2.0.

Now this works:
0:003> .loadby sos.dll mscorwks

Now I can use all sos commands on my test program.



0:032> .symfix
0:032> .sympath
Symbol search path is: srv*
Expanded Symbol search path is: cache*;SRV*http://msdl.microsoft.com/download/symbols
0:032> .cordll -ve -u -l
CLRDLL: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscordacwks.dll:2.0.50727.5472 f:0
doesn't match desired version 2.0.50727.4241 f:0
CLRDLL: Unable to find mscordacwks_x86_AMD64_2.0.50727.4241.dll by mscorwks search
CLRDLL: Unable to find 'mscordacwks_x86_AMD64_2.0.50727.4241.dll' on the path
CLRDLL: Unable to get version info for 'C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x86\sym\mscorwks.dll\5174F36C9a3000\mscordacwks_x86_AMD64_2.0.50727.4241.dll', Win32 error 0n87
CLRDLL: ERROR: Unable to load DLL mscordacwks_x86_AMD64_2.0.50727.4241.dll, Win32 error 0n87
CLR DLL status: ERROR: Unable to load DLL mscordacwks_x86_AMD64_2.0.50727.4241.dll, Win32 error 0n87

I found something here:

http://stackoverflow.com/questions/15251082/windbg-expects-different-version-of-mscordacwks-dll

and I will try tomorrow. But until then, I am going to try some commands on my machine so I am ready to debug the customer tomorrow:

0:003> !DumpDomain
*********************************************************************
* Symbols can not be loaded because symbol path is not initialized. *
*                                                                   *
* The Symbol Path can be set by:                                    *
*   using the _NT_SYMBOL_PATH environment variable.                 *
*   using the -y <symbol_path> argument when starting the debugger. *
*   using .sympath and .sympath+                                    *
*********************************************************************
PDB symbol for mscorwks.dll not loaded
--------------------------------------
System Domain:
LowFrequencyHeap: 69d09174
HighFrequencyHeap: 69d091c0
StubHeap: 69d0920c
Stage: OPEN
Name: None
--------------------------------------
Shared Domain: 69d08aa0
LowFrequencyHeap: 69d08ac4
HighFrequencyHeap: 69d08b10
StubHeap: 69d08b5c
Stage: OPEN
Name: None
Assembly: 00703580
--------------------------------------
Domain 1: 006ea1b0
LowFrequencyHeap: 006ea1d4
HighFrequencyHeap: 006ea220
StubHeap: 006ea26c
Stage: OPEN
SecurityDescriptor: 006eae98
Name: TestConsoleApp.exe
Assembly: 00703580 [C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll]
ClassLoader: 007035f0
SecurityDescriptor: 00704e70
  Module Name
5f9d1000 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll
001c2360 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sortkey.nlp
001c2010 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sorttbls.nlp

Assembly: 00711fa0 [C:\temp\TestConsoleApp\TestConsoleApp\bin\Debug\TestConsoleApp.exe]
ClassLoader: 00712010
SecurityDescriptor: 00711f18
  Module Name
00162f2c C:\temp\TestConsoleApp\TestConsoleApp\bin\Debug\TestConsoleApp.exe

// Let us examine the TestConsoleApp module

0:003> !DumpModule -mt 00162f2c
Name: C:\temp\TestConsoleApp\TestConsoleApp\bin\Debug\TestConsoleApp.exe
Attributes: PEFile
Assembly: 00711fa0
LoaderHeap: 00000000
TypeDefToMethodTableMap: 00160148
TypeRefToMethodTableMap: 00160154
MethodDefToDescMap: 001601a8
FieldDefToDescMap: 001601b8
MemberRefToDescMap: 001601bc
FileReferencesMap: 00160214
AssemblyReferencesMap: 00160218
MetaData start address: 013620a8 (1548 bytes)

Types defined in this module

      MT    TypeDef Name
------------------------------------------------------------------------------
001632ec 0x02000002 TestConsoleApp.Program

Types referenced in this module

      MT    TypeRef Name
------------------------------------------------------------------------------
5fc40964 0x01000001 System.Object
5fc446b4 0x01000012 System.Console
5fc42f94 0x01000013 System.Int32
5fc40d48 0x01000014 System.String

//Now, let us examine the type Program:

0:003> !DumpMT -md 001632ec
EEClass: 0016135c
Module: 00162f2c
Name: TestConsoleApp.Program
mdToken: 02000002  (C:\temp\TestConsoleApp\TestConsoleApp\bin\Debug\TestConsoleApp.exe)
BaseSize: 0xc
ComponentSize: 0x0
Number of IFaces in IFaceMap: 0
Slots in VTable: 7
--------------------------------------
MethodDesc Table
   Entry MethodDesc      JIT Name
5fb96a90   5fa14954   PreJIT System.Object.ToString()
5fb96ab0   5fa1495c   PreJIT System.Object.Equals(System.Object)
5fb96b20   5fa1498c   PreJIT System.Object.GetHashCode()
5fc07720   5fa149b0   PreJIT System.Object.Finalize()
0016c019   001632e4     NONE TestConsoleApp.Program..ctor()
00430070   001632cc      JIT TestConsoleApp.Program.Main(System.String[])
004300b0   001632d8      JIT TestConsoleApp.Program.runme()




Let us give the crash dump another try. I load it up in windbg and nothing works:

0:032> .sympath SRV*http://msdl.microsoft.com/download/symbols
Symbol search path is: SRV*http://msdl.microsoft.com/download/symbols
Expanded Symbol search path is: srv*http://msdl.microsoft.com/download/symbols
0:032> .exepath SRV*http://msdl.microsoft.com/download/symbols
Executable image search path is: SRV*http://msdl.microsoft.com/download/symbols
Expanded Executable image search path is: srv*http://msdl.microsoft.com/download/symbols
0:032> .cordll -ve -u -l
CLRDLL: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscordacwks.dll:2.0.50727.5472 f:0
doesn't match desired version 2.0.50727.4241 f:0
CLRDLL: Unable to find mscordacwks_x86_AMD64_2.0.50727.4241.dll by mscorwks search
CLRDLL: Unable to find 'mscordacwks_x86_AMD64_2.0.50727.4241.dll' on the path
CLRDLL: Unable to get version info for 'C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x86\sym\mscorwks.dll\5174F36C9a3000\mscordacwks_x86_AMD64_2.0.50727.4241.dll', Win32 error 0n87
CLRDLL: ERROR: Unable to load DLL mscordacwks_x86_AMD64_2.0.50727.4241.dll, Win32 error 0n87
CLR DLL status: ERROR: Unable to load DLL mscordacwks_x86_AMD64_2.0.50727.4241.dll, Win32 error 0n87


0:003> lmvm mscorwks
start    end        module name
697a0000 69d4d000   mscorwks   (deferred)
    Image path: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
    Image name: mscorwks.dll
    Timestamp:        Sun Apr 21 23:49:13 2013 (5174DD69)
    CheckSum:         005B6329
    ImageSize:        005AD000
    File version:     2.0.50727.5472
    Product version:  2.0.50727.5472
    File flags:       0 (Mask 3F)
    File OS:          4 Unknown Win32
    File type:        2.0 Dll
    File date:        00000000.00000000
    Translations:     0409.04b0
    CompanyName:      Microsoft Corporation
    ProductName:      Microsoft® .NET Framework
    InternalName:     mscorwks.dll
    OriginalFilename: mscorwks.dll
    ProductVersion:   2.0.50727.5472
    FileVersion:      2.0.50727.5472 (Win7SP1GDR.050727-5400)
    FileDescription:  Microsoft .NET Runtime Common Language Runtime - WorkStation
    LegalCopyright:   © Microsoft Corporation.  All rights reserved.
    Comments:         Flavor=Retail

Well, no wonder it does not work, it is version 5472 where the dump was built with 4241.

I find something on stackoverflow: http://stackoverflow.com/questions/5561464/how-can-i-download-correct-versions-of-mscordacwks-and-mscorwks , try it but no help



The customer session

We go on the customer call. After making sure .net version and target platform are correct, we can load the dlls properly on the customer machine. Here is the log:

Loading debug dlls


0:032> .loadby sos mscordacwoks
Unable to find module 'mscordacwoks'
0:032> .load C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscordacwks.dll
0:032> .load C:\Windows\Microsoft.NET\Framework64\v2.0.50727\sos.dll
------------------------------------------------------------
sos.dll needs a full memory dump for complete functionality.
You can create one with .dump /ma <filename>
------------------------------------------------------------
0:032> .load sos mscorwks
The call to LoadLibrary(sos mscorwks) failed, Win32 error 0n2
    "The system cannot find the file specified."
Please check your debugger configuration and/or network access.
0:032> .load C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll

Thread and exception analysis

0:032> !CLRThreads
No export CLRThreads found
CLRThreads did not work 0:032> !Threads
PDB symbol for mscorwks.dll not loaded
ThreadCount: 21
UnstartedThread: 0
BackgroundThread: 21
PendingThread: 0
DeadThread: 0
Hosted Runtime: no
                                              PreEmptive                                                Lock
       ID OSID        ThreadOBJ     State   GC     GC Alloc Context                  Domain           Count APT Exception
   6    1  4bc 00000000023e5ca0      8220 Enabled  0000000000000000:0000000000000000 00000000023da8d0     0 Ukn
  21    2 2180 0000000002407630      b220 Enabled  0000000000000000:0000000000000000 00000000023da8d0     0 Ukn (Finalizer)
  23    5 2054 00000000071a7720   200b220 Enabled  0000000000000000:0000000000000000 00000000023da8d0     0 Ukn
  24    6 192c 00000000071dcd00   880b220 Enabled  0000000000000000:0000000000000000 00000000023da8d0     0 Ukn (Threadpool Completion Port)
  26    7 1474 0000000007a65fa0    80a220 Enabled  0000000000000000:0000000000000000 00000000023da8d0     0 Ukn (Threadpool Completion Port)
  27    8 1f74 0000000007a98130   180b220 Enabled  00000001afeed820:00000001afeeee38 00000000023da8d0     0 Ukn (Threadpool Worker) System.InvalidOperationException (000000015f9d4880)
  28    9 1c84 0000000007a98be0   180b220 Enabled  000000016fa425b8:000000016fa434e0 00000000023da8d0     0 Ukn (Threadpool Worker) System.InvalidOperationException (00000001af975ba0)
  29    a 2234 0000000007ac7d40   180b220 Enabled  000000017fa349c0:000000017fa34b08 00000000023da8d0     0 Ukn (Threadpool Worker) System.InvalidOperationException (000000017f9ae990)
  30    b 24b4 0000000007ac8bf0   180b220 Enabled  000000019fa04d68:000000019fa05880 00000000023da8d0     0 Ukn (Threadpool Worker) System.InvalidOperationException (000000018f972cd0)
  31    c 1050 0000000007ac96a0   180b220 Enabled  00000001afeebe98:00000001afeece38 00000000023da8d0     0 Ukn (Threadpool Worker) System.InvalidOperationException (000000019f979048)
  32    d 1634 0000000007af3680   180b220 Enabled  00000001afef0048:00000001afef0e38 00000000023da8d0     1 Ukn (Threadpool Worker) System.InvalidOperationException (00000001afeefc90)
  33    e 2530 0000000007acf500   180b220 Enabled  00000000ffaabc08:00000000ffaadae8 00000000023da8d0     0 Ukn (Threadpool Worker) System.InvalidOperationException (00000000ffa23410)
  34    f 2300 0000000007acffb0   180b220 Enabled  000000010f9e76a0:000000010f9e88d8 00000000023da8d0     0 Ukn (Threadpool Worker) System.InvalidOperationException (000000010f970760)
  35   10 21b8 0000000007ad0e60   200b220 Enabled  0000000000000000:0000000000000000 00000000023da8d0     0 Ukn
  36   11 1f0c 000000000242f690   180b220 Enabled  000000012f9f44c0:000000012f9f6418 00000000023da8d0     0 Ukn (Threadpool Worker) System.InvalidOperationException (00000001afa5bbf8)
  37   12 15dc 0000000007b0ae90   200b220 Enabled  000000013f976a88:000000013f978950 00000000023da8d0     1 Ukn
  38   13 1b48 0000000007bd83b0    80a220 Enabled  0000000000000000:0000000000000000 00000000023da8d0     0 Ukn (Threadpool Completion Port)
  41   14 2340 0000000007c06780   180b220 Enabled  000000011f9f7c30:000000011f9f9a40 00000000023da8d0     0 Ukn (Threadpool Worker) System.InvalidOperationException (000000018f974368)
  45   15 254c 0000000007ba06e0   200b220 Enabled  000000018f974628:000000018f9764c8 00000000023da8d0     0 Ukn
   2   16 19e8 0000000007370f00       220 Enabled  0000000000000000:0000000000000000 00000000023da8d0     0 Ukn
  46   17 1ba0 00000000073714d0   180b220 Enabled  000000017fa36770:000000017fa36b08 00000000023da8d0     0 Ukn (Threadpool Worker) System.InvalidOperationException (000000016f9c8278)
0:032> ~32s
kernel32!RaiseException+0x3d:
00000000`777d715d 4881c4c8000000  add     rsp,0C8h
0:032> !analyze -v
*******************************************************************************
*                                                                             *
*                        Exception Analysis                                   *
*                                                                             *
*******************************************************************************

*** WARNING: Unable to verify checksum for System.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for System.ni.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for ntdll.dll -
*** WARNING: Unable to verify checksum for mscorlib.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for mscorlib.ni.dll
***** OS symbols are WRONG. Please fix symbols to do analysis.

*************************************************************************
***                                                                   ***
***                                                                   ***
***    Either you specified an unqualified symbol, or your debugger   ***
***    doesn't have full symbol information.  Unqualified symbol      ***
***    resolution is turned off by default. Please either specify a   ***
***    fully qualified symbol module!symbolname, or enable resolution ***
***    of unqualified symbols by typing ".symopt- 100". Note that   ***
***    enabling unqualified symbol resolution with network symbol     ***
***    server shares in the symbol path may cause the debugger to     ***
***    appear to hang for long periods of time when an incorrect      ***
***    symbol name is typed or the network symbol server is down.     ***
***                                                                   ***
***    For some commands to work properly, your symbol path           ***
***    must point to .pdb files that have full type information.      ***
***                                                                   ***
***    Certain .pdb files (such as the public OS symbols) do not      ***
***    contain the required information.  Contact the group that      ***
***    provided you with these symbols if you need this command to    ***
***    work.                                                          ***
***                                                                   ***
***    Type referenced: nt!IMAGE_NT_HEADERS32                         ***
***                                                                   ***
*************************************************************************
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for ole32.dll -
*** ERROR: Module load completed but symbols could not be loaded for dllhost.exe
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for advapi32.dll -
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for rpcrt4.dll -
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for user32.dll -
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for comsvcs.dll -
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for msvcrt.dll -
*** WARNING: Unable to verify checksum for System.EnterpriseServices.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for System.EnterpriseServices.ni.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for aspnet_perf.dll -
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for aspnet_perf.dll -
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for perfdisk.dll -

FAULTING_IP:
kernel32!RaiseException+3d
00000000`777d715d 4881c4c8000000  add     rsp,0C8h

EXCEPTION_RECORD:  ffffffffffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 00000000777d715d (kernel32!RaiseException+0x000000000000003d)
   ExceptionCode: e0434f4d (CLR exception)
  ExceptionFlags: 00000001
NumberParameters: 1
   Parameter[0]: ffffffff80131509

DEFAULT_BUCKET_ID:  WRONG_SYMBOLS

PROCESS_NAME:  dllhost.exe

ADDITIONAL_DEBUG_TEXT:
You can run '.symfix; .reload' to try to fix the symbol path and load symbols.

FAULTING_MODULE: 00000000778f0000 ntdll

DEBUG_FLR_IMAGE_TIMESTAMP:  0

ERROR_CODE: (NTSTATUS) 0xe0434f4d - <Unable to get error code text>

EXCEPTION_CODE: (NTSTATUS) 0xe0434f4d - <Unable to get error code text>

EXCEPTION_PARAMETER1:  ffffffff80131509

APP:  dllhost.exe

MANAGED_STACK:
SP               IP               Function
    000000000883F070 000007FEF61F9733 System_ni!System.Diagnostics.PerformanceCounterLib.GetCategorySample(System.String, System.String)+0x1bc013
    000000000883F0B0 000007FEF602F04D System_ni!System.Diagnostics.PerformanceCounterCategory.GetCounterInstances(System.String, System.String)+0x5d
....................
mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x9c
    000000000883F2F0 000007FEF390E9D7 mscorlib_ni!System.Threading._TimerCallback.PerformTimerCallback(System.Object)+0x87

StackTraceString: <none>
HResult: 80131509

EXCEPTION_OBJECT: !pe 1afeefc90
Exception object: 00000001afeefc90
Exception type: System.InvalidOperationException
Message: Category does not exist.
InnerException: <none>
StackTrace (generated):
    SP               IP               Function
    000000000883F070 000007FEF61F9733 System_ni!System.Diagnostics.PerformanceCounterLib.GetCategorySample(System.String, System.String)+0x1bc013
    000000000883F0B0 000007FEF602F04D System_ni!System.Diagnostics.PerformanceCounterCategory.GetCounterInstances(System.String, System.String)+0x5d
........................
mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x9c
    000000000883F2F0 000007FEF390E9D7 mscorlib_ni!System.Threading._TimerCallback.PerformTimerCallback(System.Object)+0x87

StackTraceString: <none>
HResult: 80131509

MANAGED_OBJECT: !dumpobj 1afa26f68
Name: System.String
MethodTable: 000007fef39f79e0
EEClass: 000007fef35fe530
Size: 74(0x4a) bytes
 (C:\Windows\assembly\GAC_64\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)
String: Category does not exist.
Fields:
              MT    Field   Offset                 Type VT     Attr            Value Name
000007fef39fec50  4000096        8         System.Int32  1 instance               25 m_arrayLength
000007fef39fec50  4000097        c         System.Int32  1 instance               24 m_stringLength
000007fef39f9428  4000098       10          System.Char  1 instance               43 m_firstChar
000007fef39f79e0  4000099       20        System.String  0   shared           static Empty
                                 >> Domain:Value Unable to get AppDomain 23da8d0
000007fef39f92d8  400009a       28        System.Char[]  0   shared           static WhitespaceChars
                                 >> Domain:Value Unable to get AppDomain 23da8d0

EXCEPTION_MESSAGE:  Category does not exist.

MANAGED_OBJECT_NAME:  SYSTEM.INVALIDOPERATIONEXCEPTION

MANAGED_STACK_COMMAND:  !pe 1afeefc90


LAST_CONTROL_TRANSFER:  from 000007fef64189ad to 00000000777d715d

PRIMARY_PROBLEM_CLASS:  WRONG_SYMBOLS

BUGCHECK_STR:  APPLICATION_FAULT_WRONG_SYMBOLS_CLR_EXCEPTION

STACK_TEXT:
00000000`0883f070 00000000`ffffffff system_ni!System.Diagnostics.PerformanceCounterLib.GetCategorySample+0x1bc013
00000000`0883f0b0 00000000`ffffffff system_ni!System.Diagnostics.PerformanceCounterCategory.GetCounterInstances+0x5d
.........................................
00000000`0883f2a0 00000000`ffffffff mscorlib_ni!System.Threading.ExecutionContext.Run+0x9c
00000000`0883f2f0 00000000`ffffffff mscorlib_ni!System.Threading._TimerCallback.PerformTimerCallback+0x87


FOLLOWUP_IP:
unknown!fillpattern+0
00000000`ffffffff 0000            add     byte ptr [rax],al

SYMBOL_STACK_INDEX:  2

SYMBOL_NAME:  .......

FOLLOWUP_NAME:  MachineOwner

MODULE_NAME: .......

STACK_COMMAND:  !pe 1afeefc90
 ; ** Pseudo Context ** ; kb

BUCKET_ID:  WRONG_SYMBOLS

IMAGE_NAME:  ........................dll

FAILURE_BUCKET_ID:  WRONG_SYMBOLS_e0434f4d_...................dll!d.ew.c

WATSON_STAGEONE_URL:  http://watson.microsoft.com/StageOne/dllhost_exe/6_0_6000_16386/4549bbff/kernel32_dll/6_0_6002_18740/50b58f02/e0434f4d/0001715d.htm?Retriage=1

Followup: MachineOwner
---------

0:032> !do
Invalid parameter
0:032> ~*e !CLRStack
OS Thread Id: 0x1048 (0)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x1938 (1)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x19e8 (2)
Failed to start stack walk: 80004005
OS Thread Id: 0x1ebc (3)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0xb94 (4)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0xd94 (5)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x4bc (6)
Failed to start stack walk: 80004005
OS Thread Id: 0x1bac (7)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x217c (8)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x1954 (9)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x1dc8 (10)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x267c (11)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0xe0c (12)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x1054 (13)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x8bc (14)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x2704 (15)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x1ba4 (16)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x1ad0 (17)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x1d10 (18)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x250c (19)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x1bb8 (20)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x2180 (21)
Failed to start stack walk: 80004005
OS Thread Id: 0x197c (22)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x2054 (23)
Child-SP         RetAddr          Call Site
000000000756f140 000007fef002b6dc System.Threading.WaitHandle.WaitOne(Int64, Boolean)
000000000756f180 000007fef38b275b System.EnterpriseServices.ServicedComponentProxy.QueueCleaner()
000000000756f1b0 000007fef394a7bd System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
000000000756f200 000007fef659d1e2 System.Threading.ThreadHelper.ThreadStart()
OS Thread Id: 0x192c (24)
Failed to start stack walk: 80004005
OS Thread Id: 0x1b24 (25)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x1474 (26)
Failed to start stack walk: 80004005
OS Thread Id: 0x1f74 (27)
Failed to start stack walk: 80004005
OS Thread Id: 0x1c84 (28)
Failed to start stack walk: 80004005
OS Thread Id: 0x2234 (29)
Failed to start stack walk: 80004005
OS Thread Id: 0x24b4 (30)
Failed to start stack walk: 80004005
OS Thread Id: 0x1050 (31)
Failed to start stack walk: 80004005
OS Thread Id: 0x1634 (32)
Child-SP         RetAddr          Call Site
000000000883f070 000007fef602f04c System.Diagnostics.PerformanceCounterLib.GetCategorySample(System.String, System.String)
000000000883f0b0 000007ff00376d8a System.Diagnostics.PerformanceCounterCategory.GetCounterInstances(System.String, System.String)
000000000883f100 000007ff00463bf6 d.ew.c()
000000000883f1c0 000007fef38b275b d.ew.c(System.Object)
000000000883f2a0 000007fef390e9d6 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
000000000883f2f0 000007fef659d1e2 System.Threading._TimerCallback.PerformTimerCallback(System.Object)
OS Thread Id: 0x2530 (33)
Failed to start stack walk: 80004005
OS Thread Id: 0x2300 (34)
Failed to start stack walk: 80004005
OS Thread Id: 0x21b8 (35)
Child-SP         RetAddr          Call Site
000000000907ea90 000007ff001ec7dd System.Threading.Thread.Sleep(System.TimeSpan)
000000000907ead0 000007fef38b275b d.wd.o()
000000000907eb90 000007fef394a7bd System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
000000000907ebe0 000007fef659d1e2 System.Threading.ThreadHelper.ThreadStart()
OS Thread Id: 0x1f0c (36)
Failed to start stack walk: 80004005
OS Thread Id: 0x15dc (37)
Child-SP         RetAddr          Call Site
000000000945eb50 000007fef5a7df97 System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle[], Int32, Boolean)
000000000945ebb0 000007fef38b275b System.Net.TimerThread.ThreadProc()
000000000945ec80 000007fef394a7bd System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
000000000945ecd0 000007fef659d1e2 System.Threading.ThreadHelper.ThreadStart()
OS Thread Id: 0x1b48 (38)
Failed to start stack walk: 80004005
OS Thread Id: 0x111c (39)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x1514 (40)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x2340 (41)
Failed to start stack walk: 80004005
OS Thread Id: 0x275c (42)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x2698 (43)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x23b4 (44)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x254c (45)
Child-SP         RetAddr          Call Site
0000000009dae8a0 000007ff0043453c System.Threading.Thread.Sleep(System.TimeSpan)
0000000009dae8e0 000007fef38b275b d.wa.x()
0000000009daeb20 000007fef394a7bd System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
0000000009daeb70 000007fef659d1e2 System.Threading.ThreadHelper.ThreadStart()
OS Thread Id: 0x1ba0 (46)
Failed to start stack walk: 80004005
OS Thread Id: 0xf7c (47)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x1700 (48)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process

Conclusion


If you see the output of !analyze -v , there is a stack and exception :

EXCEPTION_MESSAGE:  Category does not exist.

STACK_TEXT:
00000000`0883f070 00000000`ffffffff system_ni!System.Diagnostics.PerformanceCounterLib.GetCategorySample+0x1bc013
00000000`0883f0b0 00000000`ffffffff system_ni!System.Diagnostics.PerformanceCounterCategory.GetCounterInstances+0x5d
.........................................
00000000`0883f2a0 00000000`ffffffff mscorlib_ni!System.Threading.ExecutionContext.Run+0x9c
00000000`0883f2f0 00000000`ffffffff mscorlib_ni!System.Threading._TimerCallback.PerformTimerCallback+0x87

When we look at code, we see that this exception can leak from a timer callback. We thought the CLR would not crash when there is a leaking exception from a timer callback but that is not the case. The program exits.