什么是“Microsoft C” Visual Runtime Library:运行时错误!”我怎样才能捕捉到它?

发布于 2024-10-02 18:49:05 字数 424 浏览 13 评论 0原文

我很少收到一些用户的报告,称应用程序已自行终止,并显示以下消息框:

Microsoft C++ Visual Runtime Library

Runtime error!

Program: XXXXX.exe

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

不幸的是,应用程序在显示消息后静默终止。我们对结构化异常生成了故障转储,但由于此处没有异常,因此不会生成故障转储。

是什么原因导致此消息?

是否有某种方法可以更改应用程序,以便代替(或附加)显示消息,生成小型转储(或由应用程序完成一些其他自定义处理)?

Seldom I receive a report from some user that the application has terminated itself with a following message box:

Microsoft C++ Visual Runtime Library

Runtime error!

Program: XXXXX.exe

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Unfortunately the application terminates silenly after showing the message. We have a crash dump generation on structured exceptions, but as there is no exception here, no crash dump is generated.

What can be causing this message?

Is there some way to change the application so that instead of (or in addtion to) showing the message a minidump is generated (or some other custom handling is done by the application)?

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

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

发布评论

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

评论(2

等风来 2024-10-09 18:49:05

该消息由 abort() 生成,它可以直接调用,也可以通过设计不当的异常调用 - 请参阅意外()或终止(),如禁用 Microsoft Visual C++ 运行时错误。是否显示消息可以使用 进行调整_set_abort_behavior 调用。在 XP 及更高版本上,应用程序应默认创建小型转储并将其发送到 Windows 错误报告服务。如果您需要自定义处理程序(例如自定义故障转储),唯一(非标准)的可能性似乎是为 abort() 函数提供您自己的实现。

Microsoft C 运行时库中中止的默认实现执行以下操作:

  • 显示消息框或将消息打印到控制台
  • 如果允许错误报告,则引发 SIGABRT 处理程序
  • ,然后
    • 使用 SetUnhandledExceptionFilter(NULL) 删除未处理异常的任何处理程序
    • 使用人工准备的异常信息执行 UnhandledExceptionFilter
  • 调用 _exit(3) 来终止进程而不进行任何额外的清理

在源代码中包含以下代码使应用程序执行默认的结构化异常处理(包括您可能安装的任何过滤器):

extern "C" void __cdecl abort (void)
{
  volatile int a = 0;
  a = 1/a;
}

The message is produced by abort(), which can be called either directly, or by badly designed exceptions - see unexpected() or terminate(), as described in Disable Microsoft Visual C++ Runtime Error. Whether the message is shown or not can be adjusted using _set_abort_behavior call. On XP and later the application should create a minidump by default and send it to Windows Error Reporting service. If you need a custom handler (e.g. custom crash dump), the only (non-standard) possibility seems to be to provide your own implementation for the abort() function.

The default implementation of abort in Microsoft C Runtime Library does following:

  • shows the message box or prints the message to the console
  • raises handler for SIGABRT if there is any
  • if fault reporting is allowed, then
    • deletes any handler for unhandled exceptions using SetUnhandledExceptionFilter(NULL)
    • executes UnhandledExceptionFilter with an artificially prepared exception information
  • calls _exit(3) to terminate the process without any additional cleanup

Including a following code in your source makes the application to perform default structured exception handling (including any filter you may have installed):

extern "C" void __cdecl abort (void)
{
  volatile int a = 0;
  a = 1/a;
}
向地狱狂奔 2024-10-09 18:49:05

应用程序调用 abort() 很可能是因为在堆栈展开期间异常逃逸析构函数后调用了 terminate(),或者因为未调用异常。

请参阅答案此相关问题了解详细信息。基本上,您必须在顶层捕获并处理所有异常,而不是让异常逃脱析构函数。在调试器下启动程序并启用“抛出异常时停止”以查找内部到底出了什么问题并修复它。

The application has called abort() most likely because terminate() has been called after an exception has escaped a destructor during stack unwinding or because an exception was not called.

See an answer to this related question for details. Basically you have to catch and handle all exceptions at the top level, not let exceptions escape destructors. Start your program under debugger and enable "Stop when exception is thrown" to find what exactly is going wrong inside and fix that.

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