[Libreoffice-commits] online.git: 4 commits - loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp loolwsd/Util.cpp
Tor Lillqvist
tml at collabora.com
Fri Apr 8 12:34:11 UTC 2016
loolwsd/LOOLKit.cpp | 4 ++++
loolwsd/LOOLWSD.cpp | 2 --
loolwsd/Util.cpp | 31 ++++++++++++++++++++++++++++---
3 files changed, 32 insertions(+), 5 deletions(-)
New commits:
commit 913723e581e56eacd068588fe838b6abdadf72a1
Author: Tor Lillqvist <tml at collabora.com>
Date: Fri Apr 8 15:31:30 2016 +0300
Include the "SIG" prefix in Util::signalName()
diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp
index 34216e8..77c8cdb 100644
--- a/loolwsd/Util.cpp
+++ b/loolwsd/Util.cpp
@@ -307,7 +307,7 @@ namespace Util
{
switch (signo)
{
-#define CASE(x) case SIG##x: return #x
+#define CASE(x) case SIG##x: return "SIG" #x
CASE(HUP);
CASE(INT);
CASE(QUIT);
commit 4129b7b84ea582c93edbc4c8690c06d50eb7aeca
Author: Tor Lillqvist <tml at collabora.com>
Date: Fri Apr 8 15:29:05 2016 +0300
Don't use strsignal(), use Util::signalName()
Presumably it is only developers that are interested in signals, and
terms like SEGV or ABRT are more precise than their textual
descriptions like "Segmentation violation" or "Aborted".
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 4da8ed3..aaea71f 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1077,7 +1077,7 @@ void lokit_main(const std::string& childRoot,
}
// Sleep a second here in case we get a fatal signal just when about to finish up, which sadly
- // seems to happen often, so that the fatalSignalHandler in Util.cpp has time to produce a
+ // seems to happen often, so that handleFatalSignal() in Util.cpp has time to produce a
// backtrace.
sleep(1);
Log::info("Process finished.");
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 7cf37c4..b8becd1 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1438,7 +1438,6 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
fate = "core-dumped";
Log::error() << "Child process [" << pid << "] " << fate
<< " with " << Util::signalName(WTERMSIG(status))
- << " signal: " << strsignal(WTERMSIG(status))
<< Log::end;
break;
@@ -1447,7 +1446,6 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
{
Log::info() << "Child process [" << pid << "] stopped with "
<< Util::signalName(WSTOPSIG(status))
- << " signal: " << strsignal(WTERMSIG(status))
<< Log::end;
}
else if (WIFCONTINUED(status))
diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp
index ce65ec9..34216e8 100644
--- a/loolwsd/Util.cpp
+++ b/loolwsd/Util.cpp
@@ -393,7 +393,7 @@ namespace Util
log_signal(LogPrefix);
log_signal(" Termination signal received: ");
- log_signal(strsignal(signal));
+ log_signal(signalName(signal).c_str());
log_signal("\n");
}
}
@@ -419,7 +419,7 @@ namespace Util
{
log_signal(LogPrefix);
log_signal(" Fatal signal received: ");
- log_signal(strsignal(signal));
+ log_signal(signalName(signal).c_str());
log_signal("\n");
if (std::getenv("LOOL_DEBUG"))
commit f7612b989a6f1129520d61b652e52922ff65025e
Author: Tor Lillqvist <tml at collabora.com>
Date: Fri Apr 8 15:22:52 2016 +0300
Give a potential handleFatalSignal() time do its job
Sleep a second before exiting in case we get a fatal signal just when
about to finish, which sadly seems to happen often. (In fact, if
handleFatalSignal() is running at the same time, it will kill the
process so we never get to the _Exit() call.)
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 82e81ac..4da8ed3 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1076,6 +1076,10 @@ void lokit_main(const std::string& childRoot,
Log::error(std::string("Exception: ") + exc.what());
}
+ // Sleep a second here in case we get a fatal signal just when about to finish up, which sadly
+ // seems to happen often, so that the fatalSignalHandler in Util.cpp has time to produce a
+ // backtrace.
+ sleep(1);
Log::info("Process finished.");
std::_Exit(Application::EXIT_OK);
}
commit fb0f31d2e81eafd45044a914a05eacd706f54c17
Author: Tor Lillqvist <tml at collabora.com>
Date: Fri Apr 8 15:22:22 2016 +0300
Print a backtrace on fatal signals
diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp
index 5e2bd92..ce65ec9 100644
--- a/loolwsd/Util.cpp
+++ b/loolwsd/Util.cpp
@@ -7,8 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <execinfo.h>
#include <sys/poll.h>
#include <sys/prctl.h>
+#include <sys/uio.h>
#include <cassert>
#include <cstdlib>
@@ -433,6 +435,29 @@ namespace Util
action.sa_handler = SIG_DFL;
sigaction(signal, &action, NULL);
+
+ const int maxSlots = 50;
+ void *backtraceBuffer[maxSlots];
+ int numSlots = backtrace(backtraceBuffer, maxSlots);
+ if (numSlots > 0)
+ {
+ char **symbols = backtrace_symbols(backtraceBuffer, numSlots);
+ if (symbols != NULL)
+ {
+ struct iovec ioVector[maxSlots*2+1];
+ ioVector[0].iov_base = (void*)"Backtrace:\n";
+ ioVector[0].iov_len = std::strlen((const char*)ioVector[0].iov_base);
+ for (int i = 0; i < numSlots; i++)
+ {
+ ioVector[1+i*2+0].iov_base = symbols[i];
+ ioVector[1+i*2+0].iov_len = std::strlen((const char *)ioVector[1+i*2+0].iov_base);
+ ioVector[1+i*2+1].iov_base = (void*)"\n";
+ ioVector[1+i*2+1].iov_len = 1;
+ }
+ writev(STDERR_FILENO, ioVector, numSlots*2+1);
+ }
+ }
+
// let default handler process the signal
kill(Poco::Process::id(), signal);
}
More information about the Libreoffice-commits
mailing list