[Libreoffice-commits] online.git: loolwsd/Util.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Thu Jan 21 07:44:56 PST 2016


 loolwsd/Util.cpp |   26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

New commits:
commit 11f7746640df5d97d9adcc259017402512ed917f
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Tue Jan 19 20:06:23 2016 -0500

    loolwsd: avoid reentering Poco::Log and deadlocking while handling signal
    
    Change-Id: I3ee16ac32a337a9e1ff798495d45fb1359f4f063
    Reviewed-on: https://gerrit.libreoffice.org/21674
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp
index 44baa40..ec8d9b9 100644
--- a/loolwsd/Util.cpp
+++ b/loolwsd/Util.cpp
@@ -418,17 +418,23 @@ namespace Util
     static
     void handleSignal(int aSignal)
     {
-        Log::info() << "Signal received: " << strsignal(aSignal) << Log::end;
-        TerminationFlag = true;
-        TerminationState = ( aSignal == SIGTERM ? LOOLState::LOOL_ABNORMAL : LOOLState::LOOL_STOPPING );
-
-        if (aSignal == SIGSEGV || aSignal == SIGBUS)
+        if (!TerminationFlag)
         {
-            Log::error() << "\nSegfault! Stalling for 10 seconds to attach debugger. Use:\n"
-                         << "sudo gdb --pid=" << Poco::Process::id() << "\n or \n"
-                         << "sudo gdb --q --n --ex 'thread apply all backtrace full' --batch --pid="
-                         << Poco::Process::id() << "\n" << Log::end;
-            sleep(10);
+            // Poco::Log takes a lock that isn't recursive.
+            // If we are signaled while having that lock,
+            // logging again will deadlock on it.
+            TerminationFlag = true;
+            TerminationState = ( aSignal == SIGTERM ? LOOLState::LOOL_ABNORMAL : LOOLState::LOOL_STOPPING );
+
+            Log::info() << "Signal received: " << strsignal(aSignal) << Log::end;
+            if (aSignal == SIGSEGV || aSignal == SIGBUS)
+            {
+                Log::error() << "\nSegfault! Attach debugger with:\n"
+                             << "sudo gdb --pid=" << Poco::Process::id() << "\n or \n"
+                             << "sudo gdb --q --n --ex 'thread apply all backtrace full' --batch --pid="
+                             << Poco::Process::id() << "\n" << Log::end;
+                sleep(10);
+            }
         }
     }
 


More information about the Libreoffice-commits mailing list