未处理且无法捕获的 System.AccessViolationException

发布于 12-13 02:12 字数 6277 浏览 4 评论 0原文

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

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

提前致谢!

0:000> !CLRStack -p 操作系统线程 ID: 0x748 (0) ESP EIP
0012d44c 7c90e514 [InlinedCallFrame: 0012d44c] 系统.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, 系统.Windows.Forms.ApplicationContext) 参数: 这= 0x0153d9ec 原因=0x00000004 上下文 = 0x0226ec58

0012d538 7b1d8811 System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, 系统.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(系统异常) 参数: 这= 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 参数= l 参数 =

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 上一个事件ID = 0xffffffff

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

0012ec64 04b21ac4 Workstation.FrontScreenForm.btnSiteCheck_Click(System.Object, 系统.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 参数= l 参数 =

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, 系统.Windows.Forms.ApplicationContext) 参数: 这= 0x0153d9ec 原因=0xffffffff 上下文 = 0x015fdcd4

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

0012f350 7b195921 System.Windows.Forms.Application.Run(System.Windows.Forms.Form) 参数: 主窗体 =

0012f364 00f809df 工作站.Program.Main() 0012f688 79e71b4c [GC帧:0012f688]

While stress testing our application we always seem to suffer a catastrophic AccessViolationException after around 10-12 hours of use.

Using WinDbg to locate the source I see that it seems to originate from the native form's message loop. It would be great if someone would confirm my suspicion so I include a full stack trace with parameters. I have also taken a full stack trace if anyone needs more information.

Thanks in advance!

0:000> !CLRStack -p OS Thread 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)
PARAMETERS:
this = 0x015fe94c
dwComponentID =
reason = 0x00000004
pvLoopData = 0x00000000

0012d4e4 7b1d89c7
System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32,
System.Windows.Forms.ApplicationContext)
PARAMETERS:
this = 0x0153d9ec
reason = 0x00000004
context = 0x0226ec58

0012d538 7b1d8811
System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32,
System.Windows.Forms.ApplicationContext)
PARAMETERS:
this =
reason =
context =

0012d568 7b6ede47
System.Windows.Forms.Application.RunDialog(System.Windows.Forms.Form)
PARAMETERS:
form =

0012d57c 7b7225cb
System.Windows.Forms.Form.ShowDialog(System.Windows.Forms.IWin32Window)
PARAMETERS:
this = 0x02265860
owner =

0012d608 7b7227e3 System.Windows.Forms.Form.ShowDialog()
PARAMETERS:
this =

0012d60c 7b6eefa2
System.Windows.Forms.Application+ThreadContext.OnThreadException(System.Exception)
PARAMETERS:
this = 0x0153d9ec
t = 0x02265600

0012d648 7b6f7936
System.Windows.Forms.Control.WndProcException(System.Exception)
PARAMETERS:
this =
e =

0012d654 7b6fa3bc
System.Windows.Forms.Control+ControlNativeWindow.OnThreadException(System.Exception)
PARAMETERS:
this =
e =

0012d658 7b1c8502 System.Windows.Forms.NativeWindow.Callback(IntPtr,
Int32, IntPtr, IntPtr)
PARAMETERS:
this = 0x01a9c930
hWnd =
msg = 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)
PARAMETERS:
hWnd =

0012e8a8 7b19eb5a System.Windows.Forms.NativeWindow.DestroyHandle()
PARAMETERS:
this = 0x01a96d08

0012e8ec 7b1b9050 System.Windows.Forms.Control.DestroyHandle()
PARAMETERS:
this = 0x01a967a8

0012e8f0 7b7226bc [InlinedCallFrame: 0012e8f0] 0012ea04 7b7227e3
System.Windows.Forms.Form.ShowDialog()
PARAMETERS:
this =

0012ea08 04bf3a7b
Workstation.FrontScreenForm.HandleNewEvent(GroupsRow, Int16, Int64)
PARAMETERS:
this = 0x0153b26c
Group = 0x01a8de34
EventTypeID = 0x00000003
previousEventID = 0xffffffff

0012ec50 04bf344f
Workstation.FrontScreenForm.HandleNewEvent(GroupsRow, Int16)
PARAMETERS:
this = 0x0153b26c
Group = 0x01a8de34
EventTypeID = 0x00000003

0012ec64 04b21ac4
Workstation.FrontScreenForm.btnSiteCheck_Click(System.Object,
System.EventArgs)
PARAMETERS:
this = 0x0153b26c
sender = 0x01546a44
e = 0x0153e990

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

0012ecec 7b18f56a
System.Windows.Forms.Button.OnClick(System.EventArgs)
PARAMETERS:
this =
e =

0012ecfc 7b734429
System.Windows.Forms.ButtonBase.OnKeyUp(System.Windows.Forms.KeyEventArgs)
PARAMETERS:
this = 0x01546a44
kevent = 0x01a914c0

0012ed0c 7b6f5bf1
System.Windows.Forms.Control.ProcessKeyEventArgs(System.Windows.Forms.Message
ByRef)
PARAMETERS:
this = 0x01546a44
m = 0x0012ee44

0012ed5c 7b6f5c95
System.Windows.Forms.Control.ProcessKeyMessage(System.Windows.Forms.Message
ByRef)
PARAMETERS:
this =
m =

0012ed6c 7b6f7381
System.Windows.Forms.Control.WmKeyChar(System.Windows.Forms.Message
ByRef)
PARAMETERS:
this = 0x01546a44
m = 0x0012ee44

0012ed7c 7ba2a0ee
System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message
ByRef)
PARAMETERS:
this =
m =

0012ed80 7b1c2626 [InlinedCallFrame: 0012ed80] 0012ee18 7b1c25a0
System.Windows.Forms.Button.WndProc(System.Windows.Forms.Message
ByRef)
PARAMETERS:
this =
m =

0012ee24 7b1c8690
System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message
ByRef)
PARAMETERS:
this =
m =

0012ee2c 7b1c8611
System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message
ByRef)
PARAMETERS:
this =
m =

0012ee40 7b1c84ea System.Windows.Forms.NativeWindow.Callback(IntPtr,
Int32, IntPtr, IntPtr)
PARAMETERS:
this = 0x01546b14
hWnd =
msg = 0x00000101
wparam =
lparam =

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)
PARAMETERS:
this = 0x015fe94c
dwComponentID =
reason = 0xffffffff
pvLoopData = 0x00000000

0012f2cc 7b1d89c7
System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32,
System.Windows.Forms.ApplicationContext)
PARAMETERS:
this = 0x0153d9ec
reason = 0xffffffff
context = 0x015fdcd4

0012f320 7b1d8811
System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32,
System.Windows.Forms.ApplicationContext)
PARAMETERS:
this =
reason =
context =

0012f350 7b195921
System.Windows.Forms.Application.Run(System.Windows.Forms.Form)
PARAMETERS:
mainForm =

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

喜你已久2024-12-20 02:12:09

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

一些选项:

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

An access violation exception will not usually come from managed code, it means that your OS decided the process has done something bad (trying to access/change memory where it shouldn't) and should be terminated.
when you catch the exception with windbg (and take the dump) it is already too late.

some options:

  • Use debugdiag to take a crash dump (this will get a dump in the right place, before the exception was thrown and the process started to deconstruct) Capturing crash dumps, Download DebugDiag 1.2
  • look at the task manager after the process has run for a while and is expected to fail, (use select columns) check the GDI, handles, threads,User objects - these are all tracked resources and have limits the OS upholds, if one of them is high (in the thousands) this might be a problem.
  • look at your code, check any points that use unmanaged objcts and verify they are correctly disposed. (using COMobjects is the most common way to access unmanaged resources and these can cause an access violation, as they use OS mem allocations directly)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文