难得Winform项目中碰到dead lock,记录一下。
QA报告说,有时候晚上跑完自动化脚本,第二天早上来发现系统hang在屏保界面没反应,从日志看也没有报错。这种属于很少才会发生,也不知道怎么重现,但是很严重的bug,于是抓个dump来研究一下。
# Windbg加载dump文件后的一些文件信息
Microsoft (R) Windows Debugger Version 6.12.0002.633 AMD64 Copyright (c) Microsoft Corporation. All rights reserved. Loading Dump File [F:/DeadLock/Hang.DMP] User Mini Dump File with Full Memory: Only application data is available Symbol search path is: *** Invalid *** **************************************************************************** * Symbol loading may be unreliable without a symbol search path. * * Use .symfix to have the debugger choose a symbol path. * * After setting your symbol path, use .reload to refresh symbol locations. * **************************************************************************** Executable search path is: Windows 7 Version 7601 (Service Pack 1) MP (4 PRocs) Free x64 Product: WinNt, suite: EmbeddedNT SingleUserTS Machine Name: Debug session time: Thu Feb 27 02:47:42.000 2014 (UTC + 8:00) System Uptime: 4 days 16:41:57.807 Process Uptime: 4 days 16:41:28.000 ................................................................ Loading unloaded module list ................................................................ *** ERROR: Symbol file could not be found. Defaulted to export symbols for ntdll.dll - ntdll!NtWaitForMultipleObjects+0xa: 00000000`7706186a c3 ret |
# 设置symbol path
0:000> .sympath srv*c:/MyServerSymbols*http://msdl.microsoft.com/download/symbols Symbol search path is: srv*c:/MyServerSymbols*http://msdl.microsoft.com/download/symbols Expanded Symbol search path is: srv*c:/myserversymbols*http://msdl.microsoft.com/download/symbols |
#手动load SOS.dll,因为我们的调试机和测试机上的SOS不是同一个版本,所以不用.loadby sos clr
0:000> .load F:/SOS.dll/1008/SOS.dll |
#看看线程都在干啥
0:000> ~* e!clrstack OS Thread Id: 0xfe8 (0) Child SP IP Call Site 00000000001d5f80 000000007706186a [GCFrame: 00000000001d5f80] 00000000001d6128 000000007706186a [GCFrame: 00000000001d6128] 00000000001d60d8 000000007706186a [HelperMethodFrame_1OBJ: 00000000001d60d8] System.Threading.Monitor.Enter(System.Object) 00000000001d6220 000007ff02b1c734 TheSystem.CCDialog.OnClosed(System.EventArgs) 00000000001d62c0 000007fef18f4695 System.Windows.Forms.Form.CheckCloseDialog(Boolean)*** WARNING: Unable to verify checksum for System.Windows.Forms.ni.dll 00000000001d6330 000007fef1e64073 System.Windows.Forms.Application+ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FContinueMessageLoop(Int32, Int32, MSG[]) 00000000001d6470 000007fef12aadbe System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32) 00000000001d66b0 000007fef12aa813 System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext) 00000000001d6810 000007fef12aa1a1 System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext) 00000000001d68a0 000007fef18f8a52 System.Windows.Forms.Form.ShowDialog(System.Windows.Forms.IWin32Window) 00000000001d6c10 000007ff02c844f6 TheSystem.CCMessageBox.ShowInternal(System.Windows.Forms.Form, MessageBoxIcon, System.String, System.String, System.Windows.Forms.MessageBoxButtons, Boolean, System.Collections.Generic.Dictionary`2<System.String,System.String>, System.Windows.Forms.Control, System.Drawing.ContentAlignment) 00000000001d70e0 000007ff02c862cd TheSystem.CCMessageBox.Show(MessageBoxIcon, System.String, System.String, System.Windows.Forms.MessageBoxButtons) ......<cut to save space>...... OS Thread Id: 0x2180 (132) Child SP IP Call Site 0000000043cad940 000000007706186a [GCFrame: 0000000043cad940] 0000000043cadb98 000000007706186a [GCFrame: 0000000043cadb98] 0000000043cadb48 000000007706186a [HelperMethodFrame: 0000000043cadb48] System.Threading.Monitor.Enter(System.Object) 0000000043cadca0 000007ff02ca8a18 TheSystem.CCDialog.CloseModalDialogs() 0000000043cadd30 000007ff02ca8937 TheSystem.CCUserActivityManager.autoLogoutTimer_Elapsed(System.Object, System.Timers.ElapsedEventArgs) 0000000043cadda0 000007fef5f01b51 System.Timers.Timer.MyTimerCallback(System.Object) 0000000043cade20 000007fef6ba2f78 System.Threading.ExecutionContext.runTryCode(System.Object) 0000000043cae548 000007fef7ba44c4 [HelperMethodFrame_PROTECTOBJ: 0000000043cae548] System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object) 0000000043cae670 000007fef6b91661 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 0000000043cae6d0 000007fef6c0ced7 System.Threading._TimerCallback.PerformTimerCallback(System.Object) 0000000043cae948 000007fef7ba44c4 [GCFrame: 0000000043cae948] 0000000043caeb20 000007fef7ba44c4 [DebuggerU2MCatchHandlerFrame: 0000000043caeb20] ......<cut to save space>...... OS Thread Id: 0x363c (1076) Child SP IP Call Site 00000000d190e7a0 000000007706186a [GCFrame: 00000000d190e7a0] 00000000d190e9f8 000000007706186a [GCFrame: 00000000d190e9f8] 00000000d190e9a8 000000007706186a [HelperMethodFrame: 00000000d190e9a8] System.Threading.Monitor.Ente 新闻热点 疑难解答 |