【发布时间】:2011-02-15 16:37:01
【问题描述】:
System.AccessViolationException was unhandled
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG& msg, HandleRef hwnd, Int32 msgMin, Int32 msgMax, Int32 remove)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at ABC.Program.Main() in C:\Documents and Settings\...\Program.cs:line 17
InnerException:
这种难以重现的异常是非常不可预测的。我附加了我的 Visual Studio 调试器并运行了 7-10 次测试,并且能够成功捕获此堆栈跟踪。请注意,这些都不是我的代码,所以在 Windows 级别发生了一些令人毛骨悚然的事情。顺便说一句,我们使用 PInvoke 打开/关闭 iexplore、记事本等窗口。
经过一些 - search - 根据微软那个人的建议,我尝试使用 ADPlus 来获取内存转储和 Windbg 进行分析,但我从 windbg 获得的信息比异常本身更加神秘.
This dump file has an exception of interest stored in it.
The stored exception information can be accessed via .ecxr.
(904.1cf4): Access violation - code c0000005 (first/second chance not available)
eax=003c4d10 ebx=00000000 ecx=00000000 edx=00000000 esi=003c4d2a edi=0012f1a0
eip=003c4b64 esp=0012f11c ebp=0012f138 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010246
003c4b64 8b410c mov eax,dword ptr [ecx+0Ch] ds:0023:0000000c=????????
0:000> .ecxr
eax=003c4d10 ebx=00000000 ecx=00000000 edx=00000000 esi=003c4d2a edi=0012f1a0
eip=003c4b64 esp=0012f11c ebp=0012f138 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010246
003c4b64 8b410c mov eax,dword ptr [ecx+0Ch] ds:0023:0000000c=????????
可能有一些专家可以理解这些信息,我不能。
那么,你们如何分析这类问题呢? .Net 的“JVM 堆转储分析器”之类的东西?
环境:Windows XP SP3 [完全访问权限,管理员]
【问题讨论】:
-
您的环境和操作系统用户帐户访问权限是什么??
-
运行 WinDbg 命令时是否加载了符号和 SOS.dll?如果是这样,您可以尝试
!analyze -v了解更多信息 - 如果没有,那么我建议您从那里开始! -
@Dan - 我从here 下载了符号,命令“!analyze -v”显示了我已经拥有的堆栈跟踪(+ 一些更多信息“(NTSTATUS)0xc0000005 - 指令在“0x%08lx”引用了“0x%08lx”处的内存。内存不能是“%s”。”)..让我搜索 SOS.dll 并使用它
标签: c# winforms pinvoke windbg adplus