Skip to content

Commit 627b032

Browse files
atlauanyalldawson
authored andcommitted
Only enable qgisCrash() on FreeBSD and Linux systems with glibc
Currently, qgisCrash() is enabled on all Linux platforms except Android, but that's invalid: While glibc provides the backtrace() function, other libcs for Linux, such as musl, don't.
1 parent 0ba9a32 commit 627b032

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/app/main.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ typedef SInt32 SRefCon;
6767
#include <limits.h>
6868
#endif
6969

70-
#if ((defined(linux) || defined(__linux__)) && !defined(ANDROID)) || defined(__FreeBSD__)
70+
#if defined(__GLIBC__) || defined(__FreeBSD__)
71+
#define QGIS_CRASH
7172
#include <unistd.h>
7273
#include <execinfo.h>
7374
#include <csignal>
@@ -217,7 +218,7 @@ static void dumpBacktrace( unsigned int depth )
217218
if ( depth == 0 )
218219
depth = 20;
219220

220-
#if ((defined(linux) || defined(__linux__)) && !defined(ANDROID)) || defined(__FreeBSD__)
221+
#ifdef QGIS_CRASH
221222
// Below there is a bunch of operations that are not safe in multi-threaded
222223
// environment (dup()+close() combo, wait(), juggling with file descriptors).
223224
// Maybe some problems could be resolved with dup2() and waitpid(), but it seems
@@ -292,7 +293,7 @@ static void dumpBacktrace( unsigned int depth )
292293
#endif
293294
}
294295

295-
#if (defined(linux) && !defined(ANDROID)) || defined(__FreeBSD__)
296+
#ifdef QGIS_CRASH
296297
void qgisCrash( int signal )
297298
{
298299
fprintf( stderr, "QGIS died on signal %d", signal );
@@ -403,7 +404,7 @@ void myMessageOutput( QtMsgType type, const char *msg )
403404
case QtFatalMsg:
404405
{
405406
myPrint( "Fatal: %s\n", msg );
406-
#if (defined(linux) && !defined(ANDROID)) || defined(__FreeBSD__)
407+
#ifdef QGIS_CRASH
407408
qgisCrash( -1 );
408409
#else
409410
dumpBacktrace( 256 );
@@ -484,7 +485,7 @@ int main( int argc, char *argv[] )
484485
qInstallMsgHandler( myMessageOutput );
485486
#endif
486487

487-
#if (defined(linux) && !defined(ANDROID)) || defined(__FreeBSD__)
488+
#ifdef QGIS_CRASH
488489
signal( SIGQUIT, qgisCrash );
489490
signal( SIGILL, qgisCrash );
490491
signal( SIGFPE, qgisCrash );

0 commit comments

Comments
 (0)