如果应用程序崩溃(例如段错误或未处理的异常),由于某些 Win10 更新,它现在似乎无声无息地死了 [英] If application crashes (eg. segfault or unhandled exception), since some Win10 update it now seems to die silently

查看:22
本文介绍了如果应用程序崩溃(例如段错误或未处理的异常),由于某些 Win10 更新,它现在似乎无声无息地死了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去,无效的内存访问或应用程序中未处理的异常会导致显示某些表单消息框.

In good old time, invalid memory access or unhandled exception in application resulted in some form messagebox displayed.

在我看来,最近这不再是真的.我可以创建一个小应用程序,除了写入 NULL 指针之外什么都不做,从 Windows shell 运行它,然后它就安静地死了.

It seems to me that recently this stopped to be true. I can create a small application that does nothing else than write to NULL pointer, run it from the windows shell and it just dies silently.

我安装了 Visual C++ 命令行工具并用于编译该小应用程序(普通 C++ 和 win32 SDK).应用以 64 位模式编译.

I have Visual C++ commandline tools installed and using to compile that small app (plain C++ and win32 SDK). App is compiled in 64bit mode.

知道发生了什么吗?我真的很想念那些崩溃消息框...

Any clue what is going on? I am really missing those crash messageboxes...

推荐答案

默认情况下,此消息框是禁用的.你可以做一些事情:

It's true by default this message boxes are disabled. You can do a few things about it:

按开始并输入 gpedit.msc.然后导航到计算机配置 -> 管理模板 -> Windows 组件 -> Windows 错误报告 -> 防止显示用户界面出现严重错误 并选择 已禁用.如果您的应用程序崩溃,这至少会带回一些错误消息.

Press Start and type gpedit.msc. Than navigate to Computer Configuration -> Administrative Templates -> Windows Components -> Windows Error Reporting -> Prevent display of the user interface for critical errors and select Disabled. This will bring back at least some error messages if your application crashes.

安装异常处理程序过滤器 并过滤您想要的异常.这里的缺点是,每个抛出的异常都会调用过滤器.

Install an exception handler filter and filter for your desired exceptions. The drawback here is, the filter is called on every thrown exception.

基本上喜欢这个.

void SignalHandler(int signal)
{
    printf("Signal %d",signal);
    throw "!Access Violation!";
}

int main()
{
    typedef void (*SignalHandlerPointer)(int);

    SignalHandlerPointer previousHandler;
    previousHandler = signal(SIGSEGV , SignalHandler);
}

4.使用 Windows 错误报告

正如 IInspectable 所提到的,并在他的 answer 中描述.

选项 2 和 3 可能变得非常棘手和危险.您需要对 SEH 例外,因为不同的选项会导致不同的行为.此外,异常处理程序中并非允许所有内容,例如:写入文件被认为非常危险,甚至打印到终端.另外,由于您正在处理此异常,因此您的程序不会终止,这意味着在处理程序之后,它会立即跳回错误代码.

Option 2 and 3 can become quite tricky and dangerous. You need some basic understanding in SEH exceptions, since different options can lead to different behavior. Also, not everything is allowed in the exception handlers, e.g: writing into files is cosidered extremly dangerous, or even printing to the terminal. Plus, since you are handling this exceptions, your program won't be terminated, means after the handler, it will jump right back to the erroneous code.

这篇关于如果应用程序崩溃(例如段错误或未处理的异常),由于某些 Win10 更新,它现在似乎无声无息地死了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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