如何调查w3wp中可能死锁的线程?

时间:2014-08-05 21:42:09

标签: c# asp.net multithreading iis async-await

注意:这是尝试描述复杂问题。我会根据需要提供更多细节。

在一个非常简单的ASP MVC应用程序中(专门用于解决问题),某些http请求无法完成。浏览器工具以挂起状态显示请求,并且服务器端不会引发异常。

我已使用await关键字将问题跟踪到一行代码。

await SendJsonResponse(context, StartJsonPayload);

SendJsonResponse的实现写入HttpResponse流。当我连接调试器并在await之后的行中添加一个断点时,它永远不会被击中。

打开多个浏览器窗口后,我使用了Debug Diagnostic Tool和Process Explorer。从调试诊断工具转储文件中,我发现某些似乎挂起的线程,当我使用Process explorer时,有问题的线程似乎都有相同的跟随堆栈:

usp10.dll+0x8580
wow64cpu.dll!TurboDispatchJumpAddressEnd+0x6c0
wow64cpu.dll!TurboDispatchJumpAddressEnd+0x4a8
wow64.dll!Wow64SystemServiceEx+0x1ce
wow64.dll!Wow64LdrpInitialize+0x42a
ntdll.dll!TpAlpcRegisterCompletionList+0x7f8b
ntdll.dll!LdrInitializeThunk+0xe
ntdll.dll!NtWaitForSingleObject+0x15
kernel32.dll!WaitForSingleObjectEx+0x43
kernel32.dll!WaitForSingleObject+0x12
clr.dll+0x4187

以下是同一线程的Debug Diagnostic工具的完整堆栈跟踪。

ntdll!ZwWaitForSingleObject+15 
KERNELBASE!WaitForSingleObjectEx+98 
kernel32!WaitForSingleObjectExImplementation+75 
kernel32!WaitForSingleObject+12 
iiscore+15cc7 
iiscore+17a96 
iiscore+18e66 
webengine4!W3_MGD_HANDLER::ExplicitFlush+6e 
webengine4!MgdExplicitFlush+24 
clr!PInvokeStackImbalanceHelper+22 
System_Web_ni!DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, Boolean, Boolean ByRef)+4c 
System_Web_ni!DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, Boolean, Boolean ByRef)+4c 
[[InlinedCallFrame]] 
System_Web_ni!System.Web.Hosting.IIS7WorkerRequest.ExplicitFlush()+1a 
System_Web_ni!System.Web.Hosting.IIS7WorkerRequest.ExplicitFlush()+1a 
System_Web_ni!System.Web.HttpResponse.Flush(Boolean, Boolean)+a8 
System_Web_ni!System.Web.HttpResponse.Flush()+17 
System_Web_ni!System.Web.HttpResponse.Flush()+17 
System_Web_ni!System.Web.HttpWriter.WriteFromStream(Byte[], Int32, Int32)+3e 
System_Web_ni!System.Web.HttpResponseStream.Write(Byte[], Int32, Int32)+65 
System_Web_ni!System.Web.HttpResponseStream.Write(Byte[], Int32, Int32)+65 
Microsoft.Owin.Host.SystemWeb.CallStreams.DelegatingStream.Write(Byte[], Int32, Int32)+41 
Microsoft.Owin.Host.SystemWeb.CallStreams.OutputStream.Write(Byte[], Int32, Int32)+3e 
Microsoft.AspNet.SignalR.Owin.ServerResponse.Write(System.ArraySegment`1<Byte>)+67 
mscorlib_ni+388730 
Microsoft.AspNet.SignalR.Hosting.ResponseExtensions.End(Microsoft.AspNet.SignalR.Hosting.IResponse, System.String)+db 
Microsoft.AspNet.SignalR.PersistentConnection.SendJsonResponse(Microsoft.AspNet.SignalR.Hosting.HostContext, System.String)+d1 
Microsoft.AspNet.SignalR.PersistentConnection+<ProcessStartRequest>d__f.MoveNext()+17e 
mscorlib_ni!System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext(System.Object)+17 
mscorlib_ni!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+a7 
mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+16 
mscorlib_ni!System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run()+5b 
mscorlib_ni!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.<.cctor>b__6(System.Object)+26 
System_Web_ni!System.Web.AspNetSynchronizationContext+<>c__DisplayClass7.<Post>b__6()+10 
System_Web_ni!System.Web.Util.SynchronizationHelper.SafeWrapCallback(System.Action)+5c 
System_Web_ni!System.Web.Util.SynchronizationHelper+<>c__DisplayClass9.<QueueAsynchronous>b__7(System.Threading.Tasks.Task)+d 
mscorlib_ni!System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke()+35 
mscorlib_ni!System.Threading.Tasks.Task.Execute()+2e 
mscorlib_ni!System.Threading.Tasks.Task.ExecutionContextCallback(System.Object)+15 
mscorlib_ni!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+a7 
mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+16 
mscorlib_ni!System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)+cb 
mscorlib_ni!System.Threading.Tasks.Task.ExecuteEntry(Boolean)+b3 
mscorlib_ni!System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()+7 
mscorlib_ni!System.Threading.ThreadPoolWorkQueue.Dispatch()+149 
mscorlib_ni!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()+5 
[[DebuggerU2MCatchHandlerFrame]] 
[[ContextTransitionFrame]] 
[[DebuggerU2MCatchHandlerFrame]] 

我的问题是:

  1. 我觉得我手边有一把死锁,就是这样吗?堆栈跟踪中是否有任何指向事实的内容?
  2. 我可以使用哪些工具/技术来进一步调查此问题?
  3. 欢迎任何有助于调查此问题的建议。请提供可能的技术/工具。

0 个答案:

没有答案