Skip to content

Commit

Permalink
sighandler: break infinite loop with corrupted heap
Browse files Browse the repository at this point in the history
ignoring the segv can lead to not making progress, while churning debug.

Change-Id: I97af266cec3feefe2dcbd9adb8dbf4b13a4d69bd
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87002
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
  • Loading branch information
mmeeks committed Jan 18, 2020
1 parent c92682c commit b72f378
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions common/SigUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,16 @@ namespace SigUtil
void handleFatalSignal(const int signal)
{
SigHandlerTrap guard;
if (!guard.isExclusive())
{
Log::signalLogPrefix();
Log::signalLog(" Fatal double signal received: ");
Log::signalLog(signalName(signal));
Log::signalLog("\n Already handling a signal; will ignore this.");
return;
}
bool bReEntered = !guard.isExclusive();

Log::signalLogPrefix();
Log::signalLog(" Fatal signal received: ");

// Heap corruption can re-enter through backtrace.
if (bReEntered)
Log::signalLog(" Fatal double signal received: ");
else
Log::signalLog(" Fatal signal received: ");
Log::signalLog(signalName(signal));
Log::signalLog("\n");

struct sigaction action;

Expand All @@ -259,7 +256,8 @@ namespace SigUtil

sigaction(signal, &action, nullptr);

dumpBacktrace();
if (!bReEntered)
dumpBacktrace();

// let default handler process the signal
kill(getpid(), signal);
Expand Down

0 comments on commit b72f378

Please sign in to comment.