2011-10-31 197 views
0

在对我们的应用程序进行压力测试时,我们总是在大约10-12小时的使用后出现灾难性的AccessViolationException。未处理和无法捕捉的System.AccessViolationException

使用WinDbg来查找源代码我发现它似乎源自本机窗体的消息循环。如果有人会确认我的怀疑,那么我将会很棒,所以我会在参数中包含完整的堆栈跟踪。如果有人需要更多信息,我也会采取完整的堆栈跟踪。

在此先感谢!

0:000> CLRStack -p OS线程ID:!0x748(0)ESP EIP
0012d44c 7c90e514 [InlinedCallFrame:0012d44c] System.Windows.Forms.UnsafeNativeMethods.WaitMessage()0012d448 7b1d8ed8 系统.Windows.Forms.Application + ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(的Int32, 的Int32,Int32)将 参数: 此= 0x015fe94c dwComponentID = 原因= 0x00000004 pvLoopData = 00000000

0012d4e4 7b1d89c7 System.Windows.Forms.Application + ThreadContext.RunMessageLoopInner(的Int32, System.Windows.Forms.ApplicationContext) 参数: 此= 0x0153d9ec 原因= 0x00000004 上下文= 0x0226ec58

0012d538 7b1d8811 System.Windows.Forms.Application + ThreadContext.RunMessageLoop(的Int32, System.Windows.Forms.ApplicationContext) 参数: 此= 原因= 上下文=

0012d568 7b6ede47 System.Windows.Forms.Application.RunDialog(System.Windows.Forms.Form中) 参数: 形式=

0012d57c 7b7225cb System.Windows.Forms.Form.ShowDialog(System.Windows .Forms.IWin32Window) 参数: 此= 0x02265860 所有者=

0012d608 7b7227e3 System.Windows.Forms.Form.ShowDialog() 参数: 此=

0012d60c 7b6eefa2 System.Windows.Forms.Application + ThreadContext.OnThreadException(System.Exception的) 参数: 此= 0x0153d9ec 吨= 0x02265600

0012d648 7b6f7936 System.Windows.Forms.Control.WndProcException( System.Exception的) 参数: 此= E =

0012d654 7b6fa3bc System.Windows.Forms.Control的+ ControlNativeWindow.OnThreadException(系统。例外) 参数: 此= E =

0012d658 7b1c8502 System.Windows.Forms.NativeWindow.Callback(IntPtr的, 的Int32,IntPtr的,IntPtr的) 参数: 此= 0x01a9c930 的hWnd = 味精= 0x00000002 WPARAM = LPARAM =

0012e880 003c25e4 [NDirectMethodFrameStandalone:0012e880] System.Windows.Forms.UnsafeNativeMethods.IntDestroyWindow(System.Runtime.InteropServices.HandleRef) 0012e898 7b19ec50 System.Windows.Forms.UnsafeNativeMethods.DestroyWindow(System.Runtime.InteropServices.HandleRef) 参数: 的hWnd =

0012e8a8 7b19eb5a System.Windows.Forms.NativeWindow.DestroyHandle() 参数: 此= 0x01a96d08

0012e8ec 7b1b9050 System.Windows.Forms.Control.DestroyHandle() 参数: 此= 0x01a967a8

0012e8f0 7b7226bc [InlinedCallFrame:0012e8f0] 0012ea04 7b7227e3 System.Windows.Forms.Form.ShowDialog() 参数: 此=

0012ea08 04bf3a7b Workstation.FrontScreenForm.HandleNewEvent(GroupsRow,Int16类型,Int64的) 参数: 此= 0x0153b26c 组= 0x01a8de34 EventTypeID = 0x00000003 previousEventID = 0xFFFFFFFF的

0012ec50 04bf344f Workstation.FrontScreenForm.HandleNewEvent(GroupsRow,Int16类型) 参数: 此= 0x0153b26c 组= 0x01a8de34 EventTypeID = 0x00000003

0012ec64 04b21ac4 Workstation.FrontScreenForm.btnSiteCheck_Click(System.Object的, System.EventArgs) 参数: 此= 0x0153b26c 发件人= 0x01546a44 E = 0x0153e990

0012ecd4 7b194180 System.Windows.Forms.Control.OnClick(System.EventArgs) PARAMETERS: this = e =

0012ecec 7b18f56a System.Windows.Forms.Button.OnClick(System.EventArgs) 参数: 此= E =

0012ecfc 7b734429 System.Windows.Forms.ButtonBase.OnKeyUp(System.Windows.Forms的.KeyEventArgs) 参数: 此= 0x01546a44 KEVENT = 0x01a914c0

0012ed0c 7b6f5bf1 System.Windows.Forms.Control.ProcessKeyEventArgs(System.Windows.Forms的。消息 的ByRef) 参数: 此= 0x01546a44 米= 0x0012ee44

0012ed5c 7b6f5c95 System.Windows.Forms.Control.ProcessKeyMessage(System.Windows.Forms.Message 为ByRef) 参数: 此= 米=

0012ed6c 7b6f7381 System.Windows.Forms.Control.WmKeyChar(System.Windows.Forms.Message 为ByRef) 参数: 此= 0x01546a44 米= 0x0012ee44

0012ed7c 7ba2a0ee System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message 为ByRef) 参数: 此= 米=

0012ed80 7b1c2626 [InlinedCallFrame:0012ed80 ] 0012ee18 7b1c25a0 System.Windows.Forms.Button.WndProc(System.Windows.Forms.Message 为ByRef) 参数: 此= 米=

0 012ee24 7b1c8690 System.Windows.Forms.Control的+ ControlNativeWindow.OnMessage(System.Windows.Forms.Message 为ByRef) 参数: 此= 米=

0012ee2c 7b1c8611 System.Windows.Forms.Control的+ ControlNativeWindow .WndProc(System.Windows.Forms.Message 为ByRef) 参数: 此= 米=

0012ee40 7b1c84ea System.Windows.Forms.NativeWindow.Callback(IntPtr的, 的Int32,IntPtr的,IntPtr的) 参数: 此= 0x01546b14 的hWnd = 味精= 0x00000101 WPARAM = LPARAM =

0012f220 003c25e4 [NDirectMethodFrameStandalone:0012f220] System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG的ByRef) 0012f230 7b1d8d5e 系统。 Windows.Forms.Application + ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(的Int32, 的Int32,Int32)将 参数: 此= 0x015fe94c dwComponentID = 原因= 0xFFFFFFFF的 pvLoopData = 00000000

0012f2cc 7b1d89c7 System.Windows.Forms.Application + ThreadContext.RunMessageLoopInner(的Int32, System.Windows.Forms.ApplicationContext) 参数: 此= 0x0153d9ec 原因= 0xFFFFFFFF的 上下文= 0x015fdcd4

0012f320 7b1d8811 System.Windows.Forms.Application + ThreadContext.RunMessageLoop(的Int32, System.Windows.Forms的。的ApplicationContext) 参数: 此= 原因= 上下文=

0012f350 7b195921 System.Windows.Forms.Application.Run(System.Windows.Forms.Form中) 参数: 的MainForm =

0012f364 00f809df Workstation.Program.Main()0012f688 79e71b4c [GCFrame:0012f688]

+0

嗯,是'Workstation.FrontScreenForm'之一吗?您的应用程序似乎在ShowDialog中,但它下面有很多代码,对DoEvents()的任何调用? –

+0

在我看来,有人按了'btnSiteCheck'按钮,处理器试图显示一个新的对话框。然后事情变糟糕。对话框的消息循环中似乎出现了异常,但可能是由于销毁了对话框引起的。我建议你看看按钮点击方法发生了什么。 –

+0

您发现的来源很可能是受害者。访问冲突通常是由一个有问题的模块造成的,这个模块会破坏其他模块的内存位置,并使其成为受害者。您需要认真分析内存空间并遵循最佳实践(例如,http://blogs.msdn.com/b/tess/archive/2006/02/09/net-crash-managed-heap-corruption-calling- unmanaged-code.aspx)由于它需要太多经验,因此您可以尝试通过http://support.microsoft.com打开支持案例以咨询经验丰富的Microsoft支持人员。 –

回答

0

访问冲突异常不会通常来自魔法ged代码,这意味着你的操作系统决定进程已经做了一些坏事(试图访问/改变它不应该存储的内存)并且应该被终止。 当你用windbg捕捉异常(并转储)时,它已经太晚了。

一些选项:

  • 使用DebugDiag资料采取崩溃转储(这将获取转储在正确的地方,被抛出异常前和过程中开始解构)Capturing crash dumpsDownload DebugDiag 1.2
  • 外观在任务管理器运行了一段时间并预计会失败的情况下(使用select列),检查GDI,句柄,线程,用户对象 - 这些都是跟踪的资源,并且限制了操作系统所支持的限制,如果其中一个很高(成千上万)这可能是一个问题。
  • 查看您的代码,检查使用非托管对象的任何点并验证它们是否正确放置。 (使用COMobjects是访问非托管资源的最常见方式,因为这些资源会导致访问冲突,因为它们直接使用OS内存分配)