【问题标题】:Unhandled and Uncatchable System.AccessViolationException未处理且无法捕获的 System.AccessViolationException
【发布时间】:2011-12-18 18:36:33
【问题描述】:

在对我们的应用程序进行压力测试时,我们似乎总是在使用大约 10-12 小时后遭遇灾难性的 AccessViolationException。

使用 WinDbg 定位源我发现它似乎源自原生表单的消息循环。如果有人能证实我的怀疑,那就太好了,所以我包含一个带有参数的完整堆栈跟踪。如果有人需要更多信息,我还进行了完整的堆栈跟踪。

提前致谢!

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

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 t = 0x02265600

0012d648 7b6f7936 System.Windows.Forms.Control.WndProcException(System.Exception) 参数: 这= e =

0012d654 7b6fa3bc System.Windows.Forms.Control+ControlNativeWindow.OnThreadException(System.Exception) 参数: 这= e =

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

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 事件类型 ID = 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) 参数: 这= 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.Message 参考) 参数: 这 = 0x01546a44 m = 0x0012ee44

0012ed5c 7b6f5c95 System.Windows.Forms.Control.ProcessKeyMessage(System.Windows.Forms.Message 参考) 参数: 这= 米 =

0012ed6c 7b6f7381 System.Windows.Forms.Control.WmKeyChar(System.Windows.Forms.Message 参考) 参数: 这 = 0x01546a44 m = 0x0012ee44

0012ed7c 7ba2a0ee System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message 参考) 参数: 这= 米 =

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

0012ee24 7b1c8690 System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message 参考) 参数: 这= 米 =

0012ee2c 7b1c8611 System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message 参考) 参数: 这= 米 =

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

0012f220 003c25e4 [NDirectMethodFrameStandalone: 0012f220] System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef) 0012f230 7b1d8d5e System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32, Int32, Int32) 参数: 这 = 0x015fe94c dwComponentID = 原因 = 0xffffffff pvLoopData = 0x00000000

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) 参数: 主窗体 =

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

【问题讨论】:

  • 嗯,Workstation.FrontScreenForm 是你的吗?您的应用似乎在 ShowDialog 中,但它下面有很多代码,对 DoEvents() 的任何调用?
  • 在我看来有人按下了btnSiteCheck 按钮,处理程序试图显示一个新对话框。然后事情变糟了。该异常似乎发生在对话框的消息循环中,但可能是由于破坏了对话框句柄引起的。我建议您查看该按钮单击方法中发生的情况。
  • 您找到的来源很可能是受害者。访问冲突通常是由有问题的模块导致的,该模块破坏了其他模块的内存位置,并使它们成为受害者。您需要仔细分析内存空间并遵循最佳实践(例如,blogs.msdn.com/b/tess/archive/2006/02/09/…),因为它需要太多的经验,您可以尝试通过support.microsoft.com 打开支持案例,咨询有经验的微软支持人员。

标签: c# .net windbg access-violation


【解决方案1】:

访问冲突异常通常不会来自托管代码,这意味着您的操作系统决定进程做了坏事(试图访问/更改不应访问的内存)并且应该终止。 当您使用 windbg 捕获异常(并进行转储)时,已经为时已晚。

一些选项:

  • 使用 debugdiag 进行故障转储(这将在正确的位置获得转储,在引发异常并开始解构进程之前)Capturing crash dumpsDownload DebugDiag 1.2
  • 在进程运行一段时间并预计会失败后查看任务管理器,(使用选择列)检查 GDI、句柄、线程、用户对象 - 这些都是跟踪资源并限制了操作系统支持,如果其中一个很高(以千计),这可能是个问题。
  • 查看您的代码,检查所有使用非托管对象的点并验证它们是否正确处理。 (使用 COMobjects 是访问非托管资源的最常用方法,这些可能会导致访问冲突,因为它们直接使用 OS 内存分配)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-30
    • 2012-06-07
    • 2022-01-15
    • 2014-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多