Unhandled and Uncatchable System.AccessViolationException

2

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]

c#
.net
windbg
access-violation
asked on Stack Overflow Oct 31, 2011 by mwkenna

1 Answer

0

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)
answered on Stack Overflow Nov 26, 2012 by Amitbe

User contributions licensed under CC BY-SA 3.0