From 5040e6c7f076551e7c81feb44a8e6b27b29040a7 Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Sat, 8 Apr 2017 12:35:39 +0200 Subject: [PATCH] Don't call fatalMessageBox() from fg_terminate(), make it end with std::abort() Basically, this is because fatalMessageBox() is only safe to call from the GUI thread, however it seems fg_terminate() can be called from any thread (according to C++11 semantics). Additionally, fatalMessageBox() typically requires some work to happen in the GUI thread (event loop) in order to display something, but we can't realistically expect this while running a terminate handler just before the program dies. See messages around for a discussion of this subject. + Minor header cleanup ( replaced with , etc.) --- src/Main/bootstrap.cxx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Main/bootstrap.cxx b/src/Main/bootstrap.cxx index 9fa2b2646..5da593452 100644 --- a/src/Main/bootstrap.cxx +++ b/src/Main/bootstrap.cxx @@ -44,13 +44,13 @@ # include // for gethostname() #endif -#include -#include -#include -#include -#include #include -#include +#include +#include +#include +#include +#include +#include #include #include @@ -188,9 +188,11 @@ void segfault_handler(int signo) { } #endif -static void fg_terminate() +[[noreturn]] static void fg_terminate() { - flightgear::fatalMessageBox("Fatal exception", "Uncaught exception on some thread"); + cerr << "Running FlightGear's terminate handler. The program is going to " + "exit due to a fatal error condition, sorry." << std::endl; + std::abort(); } // Detect SSE2 support for x86, it is always available for x86_64