未处理的 Win32 异常

发布于 2024-09-08 14:37:49 字数 68 浏览 8 评论 0原文

在运行时,当 myApp.exe 崩溃时,我收到“未处理的 Win32 异常”,但我如何知道发生了哪个异常?哪里出了问题?

At runtime, when myApp.exe crashes i receive "Unhandled Win32 exception" but how would i know which exception was occurred? where did something went wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦毁影碎の 2024-09-15 14:37:49

对于本机 C++ 应用程序,请参阅我之前的答案:在 Windows 上检测/重定向核心转储(当软件崩溃时),用于捕获未处理的异常(还提供了用于创建故障转储的代码,您可以稍后使用它来分析崩溃。如果发生崩溃在开发系统上,然后在 Visual Studio 中(我假设您正在使用它,如果不是其他 IDE 也会有类似的东西),在“调试/异常”中勾选“Win32 异常”的“抛出”框。

For a Native C++ app see my earlier answer here: Detect/Redirect core dumps (when a software crashes) on Windows for catching the unhandled exception (that also gives code for creating a crash dump that you can use to analyse the crash later. If the crash is happening on a development system then in Visual Studio (I'm assuming you're using that, if not other IDEs will have something similar), in Debug/Exceptions tick the 'Thrown' box for 'Win32 Exceptions'.

兮子 2024-09-15 14:37:49

通常,Windows 也会为您提供几个十六进制数字。异常代码很可能是 0xC0000005。这是访问冲突的代码。当发生这种情况时,您还将获得另外三个信息:违规地址、违规地址和违规类型(读、写或执行)。

Windows 不会进一步缩小范围,而且通常无论如何也做不到。例如,如果您走过程序中数组的末尾,Windows 可能不会意识到您甚至在迭代数组。它只看到“读:OK,读:OK,读:越界=>页面错误=>访问违规”。您必须从违规地址(您的数组迭代代码)和违规地址(数组后面的越界地址)中找出答案。

Typically, Windows will give you several hexadecimal numbers as well. Chances are that the exception code will be 0xC0000005. This is the code of an Access Violation. When that happens, you also will have three additional bits of information: the violating address, the violated address, and the type of violation (read, write or execute).

Windows won't narrow it down any further than that, and often it couldn't anyway. For instance, if you walk past the end of an array in your program, Windows likely won't realize that you were even iterating over an array. It just sees "read:OK, read:OK, read:out of bounds => page fault => ACCESS VIOLATION". You will have to figure that out from the violating address (your array iteration code) and the violated address (the out-of-bounds address behind your array).

舂唻埖巳落 2024-09-15 14:37:49

如果它是 .Net 应用程序,您可以尝试为 UnhandledException 事件放入处理程序。您可以在此处找到有关它的更多信息和一些示例代码。

一般来说,这是一个好兆头,表明您的异常处理已被破坏,因此可能值得检查您的代码并找到可能抛出但不处理异常的位置。

If it's a .Net app you could try to put in a handledr for the UnhandledException event. You can find more information about it and some sample code here.

In general it's a good sign that your exception handling is broken though, so might be worth going through your code and finding places that could throw but where you don't handle exceptions.

夜巴黎 2024-09-15 14:37:49

使用调试器。您可以运行该程序并查看抛出的异常会终止您的应用程序。它也许能够精确定位投掷的位置。我没有为此使用VS调试器,但是在gdb中你可以使用catch throw在抛出异常时强制断点,应该有类似的东西。

Use the debugger. You can run the program and see what exception is been thrown that kills your application. It might be able to pinpoint the location of the throw. I have not used the VS debugger for this, but in gdb you can use catch throw to force a breakpoint when an exception is thrown, there should be something similar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文