Search code examples
c++20stack-tracecoroutinecrash-reports

Crash reporting and C++ Coroutines?


I use a crash reporting feature that allows the user to submit a crash report if the application crashed with an uncaught exception.

After adopting C++20 coroutines entered the application. If there is an unexpected exception thrown in a coroutine the exception is caught before it is rethrown. This causes crashreports to not show the stacktrace needed to figure out what happened, but only the stacktrace to the coroutine that rethrew the exception. This basically makes any crash reporting useless.

As far as I could find there is no way to prevent the catching of any exceptions by the coroutine because it is a required part of the design.

Is there a way to improve this I cant see? I am curious because I found nobody else complaining yet. :->

Edit: To clarify the app is running on Windows, I mean the stacktrace of a minidump that is created at the point of the unhandled exception using: SetUnhandledExceptionFilter + MiniDumpWriteDump


Solution

  • The best solution we have found is as follows (Windows specific!):

    Until now we used SetUnhandledExceptionFilter at the start of the app to set an exceptionfilter function that writes a minidump.

    Instead we now use _set_se_translator.

    If we want the program to just crash (f.e. if windows is set to write dumps) we set a function which calls std::abort.

    If we want to handle it interactively we set a function which asks the user whether to send a minidump, the dump is written as before at this point.

    Both cases provide the full callstack in the dump.

    The only downside remaining is we cant let the program crash for "normal" exceptions to dump, this was possible before. But the "most important" exceptions (f.e. access violations) work.