Question

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)?

Was it helpful?

Solution

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;
}

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top