1
0
Fork 0

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
<https://sourceforge.net/p/flightgear/mailman/message/35775803/> for a
discussion of this subject.

+ Minor header cleanup (<locale.h> replaced with <clocale>, etc.)
This commit is contained in:
Florent Rougon 2017-04-08 12:35:39 +02:00
parent 5e5699c4d8
commit 5040e6c7f0

View file

@ -44,13 +44,13 @@
# include <unistd.h> // for gethostname()
#endif
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <locale.h>
#include <cerrno>
#include <csignal>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <clocale>
#include <simgear/compiler.h>
#include <simgear/structure/exception.hxx>
@ -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