WndProc中的64位异常默认失败 [英] 64bit exceptions in WndProc silently fail

查看:616
本文介绍了WndProc中的64位异常默认失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码将在Windows 7 32位下运行时出现严重故障:

The following code will give a hard fail when run under Windows 7 32bit:

void CTestView::OnDraw(CDC* /*pDC*/)
{
    *(int*)0 = 0; // Crash

    CTestDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    if (!pDoc)
        return;

    // TODO: add draw code for native data here
}

但是,如果我在Windows 7 64bit上尝试这样做,我只需在输出窗口中输入:

However, if I try this on Windows 7 64bit, I just get this in the output window:


0x13929384
在Test.exe中:0xC0000005:访问
违规写入位置0x00000000。

第一次机会异常在0x77c6ee42
在Test.exe中:0xC0150010:
激活上下文被停用
对于当前线程
执行不活动。

First-chance exception at 0x13929384 in Test.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x77c6ee42 in Test.exe: 0xC0150010: The activation context being deactivated is not active for the current thread of execution.

是什么原因为了这?我知道这是一个硬件例外( http://msdn.microsoft.com/en -us / library / aa363082.aspx ),但为什么运行在32位和64位之间的区别?我能做些什么来正确处理这些错误?因为它们实际上应该是被困住和固定的,而是Windows目前正在发生的事情,即将消息传递给应用程序,并让它运行(因此用户和开发人员完全不知道任何问题实际上发生了)。

What is the reason for this? I know it's a hardware exception (http://msdn.microsoft.com/en-us/library/aa363082.aspx), but why the difference when ran under 32bit and 64bit? And what can I do to correctly handle these kind of errors? Because they should really be trapped and fixed, as opposed to what currently happens which is Windows just carries on pumping messages to the application and let's it run (so the user and the developers are completely unaware any problems have actually occurred).

更新:
我们的常规崩溃报告软件使用 SetUnhandledExceptionFilter 在WndProc中的硬件异常不会在x64上被调用。有没有人有这方面的信息或解决方法?

Update: Our regular crash reporting software uses SetUnhandledExceptionFilter but that doesn't get called on x64 for hardware exceptions inside a WndProc. Does anyone have any information on this, or a workaround?

Update2:
我已经报告了Microsoft Connect的问题:

https://connect.microsoft.com/VisualStudio/feedback/details/550944/hardware-exceptions-on-x64-machines-are-silently-caught-in-wndproc-messages

推荐答案

好的,我收到了微软的回复:

OK, I've received a reply from Microsoft:


您好,

Hello,

感谢您的报告。我发现
这是一个Windows问题,
有一个热修复可用。请
请参阅
http://support.microsoft.com/kb/976038
,如果您需要
,可以安装该修复程序。

Thanks for the report. I've found out that this is a Windows issue, and there is a hot fix available. Please see http://support.microsoft.com/kb/976038 for a fix that you can install if you wish.

@Skute:请注意,程序
兼容性助理将要求
如果该程序应该允许
继续执行,之后它将永远被允许
,这样可能是
导致混淆行为的原因
你看到。

@Skute: note that the Program Compatibility Assistant will ask once if the program should be allowed to continue to execute, and after that it will always be allowed, so that may be the cause of the confusing behavior you are seeing.

Pat Brenner Visual C ++库
开发

Pat Brenner Visual C++ Libraries Development

所以解决方法是确保修复程序已安装,或者使用__try / __except块将每个WndProc包装在应用程序中。

So the workaround is either make sure the hotfix is installed, or wrap each WndProc in your application with a __try / __except block.

这篇关于WndProc中的64位异常默认失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆