Exceptions silently caught by Windows, how to handle manually?

前端 未结 7 1276
一整个雨季
一整个雨季 2020-12-13 14:45

We\'re having problems with Windows silently eating exceptions and allowing the application to continue running, when the exception is thrown inside the message pump. For ex

7条回答
  •  孤街浪徒
    2020-12-13 15:13

    I experienced this same issue, and found it was a result of this Microsoft bug: http://connect.microsoft.com/VisualStudio/feedback/details/550944/hardware-exceptions-on-x64-machines-are-silently-caught-in-wndproc-messages

    There’s a fix available from Microsoft, though deploying it is somewhat challenging if you have multiple target platforms:

    http://support.microsoft.com/kb/976038

    Here's an article on the subject describing the behavior:

    http://blog.paulbetts.org/index.php/2010/07/20/the-case-of-the-disappearing-onload-exception-user-mode-callback-exceptions-in-x64/

    The issue is basically that Hardware exceptions in 32-bit programs are silently caught in the WndProc routine on 64-bit OSs, unless you send commands telling it not to. Microsoft has a hotfix for the issue that is required if you're running Vista SP2, but isn't required with Windows 7 SP1 (not sure about Win7 without the SP).

    Even WITH the hotfix, you need to enable the correct behavior by setting a registry key or making some calls to the kernel to tell it your process expects hardware exceptions to crash when encountered during WndProc.

    According to the PaulBetts link above, this was done for backwards compatibility with Windows Server 2003.

    If you program is a 64-bit program, this issue goes away.

提交回复
热议问题