我们的一位客户报告了一起车祸。她在未处理的异常后看到标准错误消息:
我使用DebugDiag生成此进程的转储。我现在在看垃圾场。
0:000> !pe -nested
...
Nested exception -------------------------------------------------------------
Exception object: 14015a98
Exception type: System.AccessViolationException
Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
InnerException: <none>
StackTrace (generated):
SP IP Function
0013E958 7B6EEF3B System_Windows_Forms_ni!System.Windows.Forms.Application+ThreadContext.OnThreadException(System.Exception)+0x8b
0013E994 7B6F7916 System_Windows_Forms_ni!System.Windows.Forms.Control.WndProcException(System.Exception)+0x16
0013E9A0 7B6FA39C System_Windows_Forms_ni!System.Windows.Forms.Control+ControlNativeWindow.OnThreadException(System.Exception)+0xc
0013E9A4 7B1C8512 System_Windows_Forms_ni!System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)+0x72
0013EC70 7B1D8D2E System_Windows_Forms_ni!System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32, Int32, Int32)+0x24e
0013ED0C 7B1D8997 System_Windows_Forms_ni!System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)+0x177
0013ED60 7B1D87E1 System_Windows_Forms_ni!System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)+0x61
0013ED90 7B6EDE2B System_Windows_Forms_ni!System.Windows.Forms.Application.RunDialog(System.Windows.Forms.Form)+0x33
0013EDA4 7B7225AB System_Windows_Forms_ni!System.Windows.Forms.Form.ShowDialog(System.Windows.Forms.IWin32Window)+0x373
0013EE30 0DF41E76 PDILibReportProcessor!profdata.com.Library.libReportRenderCrystal.RenderToDisplay(System.Windows.Forms.IWin32Window, profdata.com.Library.libOutputSettings, profdata.com.Library.libApplicationConfig)+0xb6
0013EE4C 0DF416EB PDILibReportProcessor!profdata.com.Library.libReportProcessor.Process(System.Windows.Forms.IWin32Window)+0x153
0013EE60 07B37644 PDILibReportProcessor!profdata.com.Library.libReportProcessor.ProcessCrystalReport(System.String, System.Type, System.Data.DataSet, profdata.com.Library.libOutputSettings, profdata.com.Library.libApplicationConfig, System.Windows.Forms.IWin32Window, System.String)+0x74
0013EEA4 07B375B8 PDILibReportProcessor!profdata.com.Library.libReportProcessor.ProcessReport(System.String, System.Type, System.Data.DataSet, profdata.com.Library.libOutputSettings, profdata.com.Library.libApplicationConfig, System.Windows.Forms.IWin32Window)+0x18
0013EEB8 07B333C4 APRPTCashRequirements!profdata.com.AccountsPayable.frmAPCashRequirements.RunProcessOrReport()+0x7e4
StackTraceString: <none>
HResult: 80004003
代码以表单的形式向用户显示了一个水晶报告。显示报告时,应用程序尝试执行某些操作,但得到System.AccessViolationException。
查看NativeWindow.Callback源代码,我看到以下内容:
private IntPtr Callback(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam)
{
Message m = Message.Create(hWnd, msg, wparam, lparam);
try
{
// calls WndProc or DefWndProc
}
catch (Exception exception)
{
this.OnThreadException(exception);
}
finally {...}
}
我想知道导致异常的消息、wParam和lParam参数。(我还想验证我看到的是正确的异常对象。)这可能是对UI线程的调用,也可能是正常的Windows事件,在这种情况下,我想知道是哪个事件。
我得到了线程环境块:
0:000> !teb
TEB at 7ffdf000
ExceptionList: 00134144
StackBase: 00140000
StackLimit: 00130000
0:000> !dqs 00130000 00140000
...
0013e968 00000000`00000000
0013e970 00000000`00000000
0013e978 00000000`00000000
0013e980 140ea9fc`00000000
0013e988 0013e998`0013ea44
0013e990 140c1d4c`7b6f7916
0013e998 7b6fa39c`0013ea54 <--- is NativeWindow.Callback
0013e9a0 0013ea6c`7b1c8512
0013e9a8 0013ec60`79edd757
0013e9b0 0013ec60`00000000
0013e9b8 0013ea6c`e0434f4d
0013e9c0 00000000`0013ea1c
0013e9c8 00000000`00000000
...
0013E9A4 7B1C8512本机窗口回调(IntPtr、Int32、IntPtr、IntPtr)+0x72
-
参数在哪里
那一堆?
-
我该如何检查它们
得到他们的价值观?
我仍然觉得我没有找到根本原因。我们有一个ThreadException处理程序。为什么不叫它?是什么导致了这次事故
System.AccessViolationException
?
注意
!analyze -v
报道
STATUS_BREAKPOINT
,因为用户在错误对话框“应用程序已生成异常…”处停止。