One of the most common issues I deal with are related to blocking. Some of this are pretty straight forward to identify, Others not that easy, especially if you have a process with many threads. When I have to troubleshoot blocking on WaitHandles (e.g Mutex) I usually find the need to use both user mode and kernel mode debugging to identify the guilty thread.
For demonstration purposes I’ve built a simple sample where a process appears hung. The first thing to do is to attach the debugger to the process. My sample was built with CLR 4.0 so no more mscorwks (now it´s called clr.dll). Let’s start by loading the SOS extension. 0:007> .loadby sos clr After looking at the threads stack with !clrstack we can see a thread blocked on WaitOne. (managed stack)
0:007> !clrstack
OS Thread Id: 0x1b18 (7)
Child SP IP Call Site
04fbf4f4 76fc00fd [HelperMethodFrame_1OBJ: 04fbf4f4] System.Threading.WaitHandle.WaitOneNative(System.Runtime.InteropServices.SafeHandle, UInt32, Boolean, Boolean)
04fbf59c 6a4b6eff System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle, Int64, Boolean, Boolean)
04fbf5b8 6a4b6ebd System.Threading.WaitHandle.WaitOne(Int32, Boolean)
04fbf5d0 6a4b6e80 System.Threading.WaitHandle.WaitOne()
04fbf5d8 002006c6 BlockingQueueWithManualResetEvents`1[[System.__Canon, mscorlib]].Enqueue(System.__Canon)
04fbf610 00200666 ThreadsManaged.Program+<>c__DisplayClass4.<Main>b__3()
04fbf61c 6a4d0bea System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
04fbf628 6a500b6c System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) Read more: Deviations
For demonstration purposes I’ve built a simple sample where a process appears hung. The first thing to do is to attach the debugger to the process. My sample was built with CLR 4.0 so no more mscorwks (now it´s called clr.dll). Let’s start by loading the SOS extension. 0:007> .loadby sos clr After looking at the threads stack with !clrstack we can see a thread blocked on WaitOne. (managed stack)
0:007> !clrstack
OS Thread Id: 0x1b18 (7)
Child SP IP Call Site
04fbf4f4 76fc00fd [HelperMethodFrame_1OBJ: 04fbf4f4] System.Threading.WaitHandle.WaitOneNative(System.Runtime.InteropServices.SafeHandle, UInt32, Boolean, Boolean)
04fbf59c 6a4b6eff System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle, Int64, Boolean, Boolean)
04fbf5b8 6a4b6ebd System.Threading.WaitHandle.WaitOne(Int32, Boolean)
04fbf5d0 6a4b6e80 System.Threading.WaitHandle.WaitOne()
04fbf5d8 002006c6 BlockingQueueWithManualResetEvents`1[[System.__Canon, mscorlib]].Enqueue(System.__Canon)
04fbf610 00200666 ThreadsManaged.Program+<>c__DisplayClass4.<Main>b__3()
04fbf61c 6a4d0bea System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
04fbf628 6a500b6c System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) Read more: Deviations
0 comments:
Post a Comment