Skip to content

Commit 66bccae

Browse files
committed
Merge branch 'fix/SNC-4336_handle_crash_release' into 'release/v5.2.0'
SNC-4336. Fix crash handling issue [release] See merge request desktop/desktop!2590
2 parents 18f1c00 + 6ccbe29 commit 66bccae

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/MEGASync/control/CrashHandler.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,18 @@ string getDistroVersion()
271271
write(dump_file, oss.str().c_str(), oss.str().size());
272272
close(dump_file);
273273

274+
struct sigaction sa;
275+
sa.sa_handler = SIG_DFL;
276+
sigemptyset (&sa.sa_mask);
277+
sigaction(SIGSEGV, &sa, NULL);
278+
sigaction(SIGBUS, &sa, NULL);
279+
sigaction(SIGILL, &sa, NULL);
280+
sigaction(SIGFPE, &sa, NULL);
281+
sigaction(SIGABRT, &sa, NULL);
282+
#if defined(__arm64__)
283+
sigaction(SIGTRAP, &sa, NULL);
284+
#endif
285+
274286
CrashHandler::tryReboot();
275287
exit(128+sig);
276288
}

src/MEGASync/control/MegaSyncLogger.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ struct LogLinkedList
149149
};
150150

151151
MegaSyncLogger *g_megaSyncLogger = nullptr;
152+
std::atomic<bool> gAppExit(false);
152153

153154
struct LoggingThread
154155
{
@@ -444,11 +445,16 @@ struct LoggingThread
444445

445446
};
446447

448+
void exitFunction()
449+
{
450+
gAppExit = true;
451+
}
447452

448453
MegaSyncLogger::MegaSyncLogger(QObject *parent, const QString& dataPath, const QString& desktopPath, bool logToStdout)
449454
: QObject{parent}
450455
, mDesktopPath{desktopPath}
451456
{
457+
std::atexit(exitFunction);
452458
assert(!g_megaSyncLogger);
453459
g_megaSyncLogger = this;
454460
mLogToStdout = logToStdout;
@@ -587,6 +593,11 @@ void LoggingThread::log(int loglevel, const char *message, const char **directMe
587593
// }
588594
//#endif
589595

596+
if(gAppExit)
597+
{
598+
return;
599+
}
600+
590601
bool direct = directMessages != nullptr;
591602

592603
char timebuf[LOG_TIME_CHARS + 1];

0 commit comments

Comments
 (0)