[Libreoffice-commits] online.git: loolwsd/LibreOfficeKit.hpp loolwsd/LOOLKit.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Nov 7 06:39:50 UTC 2016
loolwsd/LOOLKit.cpp | 7 ++++++-
loolwsd/LibreOfficeKit.hpp | 9 ++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
New commits:
commit 86fb4dc03bcefe198688cee00cd375112594dad7
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Nov 6 21:16:54 2016 -0500
loolwsd: extend the lifetime of lokit to avoid destroying
Lokit's destroy is prone to throw (at least in dbgutil).
This exception brings the binary down with a core-dump.
To avoid this, we extend the lifetime of lokit to the end
of the process, where we invoke std::_Exit to promptly
kill the process and exit.
For reference, the exception is thrown as follows:
#0 0x00007f0ba5a43bcd in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1 0x00007f0b76303248 in (anonymous namespace)::ModuleManager::identify (this=0x7f0b5328e6d0, xModule=empty uno::Reference) at /home/ash/prjx/cp51/framework/source/services/modulemanager.cxx:198
#2 0x00007f0b762606dc in (anonymous namespace)::JobExecutor::notifyEvent (this=0x7f0b77176b30, aEvent=...) at /home/ash/prjx/cp51/framework/source/jobs/jobexecutor.cxx:274
#3 0x00007f0ba13ea455 in (anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyJobExecution (this=0x7f0b77176a30, aEvent=...) at /home/ash/prjx/cp51/sfx2/source/notify/globalevents.cxx:397
#4 0x00007f0ba13e9346 in (anonymous namespace)::SfxGlobalEvents_Impl::documentEventOccured (this=0x7f0b77176a30, _Event=...) at /home/ash/prjx/cp51/sfx2/source/notify/globalevents.cxx:241
#5 0x00007f0ba0fe5717 in SfxTerminateListener_Impl::notifyTermination (this=0x7f0b772462c8, aEvent=...) at /home/ash/prjx/cp51/sfx2/source/appl/appinit.cxx:125
#6 0x00007f0b762ebc39 in framework::Desktop::terminate (this=0x7f0b7721d530) at /home/ash/prjx/cp51/framework/source/services/desktop.cxx:330
#7 0x00007f0ba47940ce in lo_destroy (pThis=0x154de60) at /home/ash/prjx/cp51/desktop/source/lib/init.cxx:2926
#8 0x0000000000429681 in lok::Office::~Office (this=<optimized out>, __in_chrg=<optimized out>) at LibreOfficeKit.hpp:516
#9 __gnu_cxx::new_allocator<lok::Office>::destroy<lok::Office> (this=<optimized out>, __p=<optimized out>) at /usr/include/c++/5/ext/new_allocator.h:124
#10 std::allocator_traits<std::allocator<lok::Office> >::_S_destroy<lok::Office> (__p=<optimized out>, __a=...) at /usr/include/c++/5/bits/alloc_traits.h:285
#11 std::allocator_traits<std::allocator<lok::Office> >::destroy<lok::Office> (__a=..., __p=<optimized out>) at /usr/include/c++/5/bits/alloc_traits.h:414
#12 std::_Sp_counted_ptr_inplace<lok::Office, std::allocator<lok::Office>, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0xb04f40) at /usr/include/c++/5/bits/shared_ptr_base.h:531
#13 0x000000000042dfb6 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0xb04f40) at /usr/include/c++/5/bits/shared_ptr_base.h:150
#14 0x0000000000425797 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x7ffce7430468, __in_chrg=<optimized out>) at /usr/include/c++/5/bits/shared_ptr_base.h:659
#15 std::__shared_ptr<lok::Office, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x7ffce7430460, __in_chrg=<optimized out>) at /usr/include/c++/5/bits/shared_ptr_base.h:925
#16 std::shared_ptr<lok::Office>::~shared_ptr (this=0x7ffce7430460, __in_chrg=<optimized out>) at /usr/include/c++/5/bits/shared_ptr.h:93
#17 lokit_main (childRoot="/home/ash/prj/lo/online/loolwsd/test/../jails/", sysTemplate="/home/ash/prj/lo/online/loolwsd/test/../systemplate", loTemplate="/home/ash/prj/lo/instdir", loSubPath="lo", noCapabilities=<optimized out>, queryVersion=queryVersion at entry=true, displayVersion=false) at LOOLKit.cpp:1441
#18 0x000000000041df41 in createLibreOfficeKit (childRoot="/home/ash/prj/lo/online/loolwsd/test/../jails/", sysTemplate="/home/ash/prj/lo/online/loolwsd/test/../systemplate", loTemplate="/home/ash/prj/lo/instdir", loSubPath="lo", queryVersion=queryVersion at entry=true) at LOOLForKit.cpp:228
#19 0x000000000041aea4 in main (argc=7, argv=0x7ffce7431ec8) at LOOLForKit.cpp:389
194 {
195 throw css::lang::IllegalArgumentException(
196 OUString("Given module is not a frame nor a window, controller or model."),
197 static_cast< ::cppu::OWeakObject* >(this),
198 1);
199 }
Change-Id: Idaef5e0a28021a73f4c03ee3bee80968d9c57bd5
Reviewed-on: https://gerrit.libreoffice.org/30642
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index a89ba53..50b6196 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1333,6 +1333,10 @@ void lokit_main(const std::string& childRoot,
std::string userdir_url;
std::string instdir_path;
+ // lokit's destroy typically throws from
+ // framework/source/services/modulemanager.cxx:198
+ // So we insure it lives until std::_Exit is called.
+ std::shared_ptr<lok::Office> loKit;
Path jailPath;
bool bRunInsideJail = !noCapabilities;
try
@@ -1438,7 +1442,6 @@ void lokit_main(const std::string& childRoot,
instdir_path = "/" + loTemplate + "/program";
}
- std::shared_ptr<lok::Office> loKit;
{
const char *instdir = instdir_path.c_str();
const char *userdir = userdir_url.c_str();
@@ -1490,7 +1493,9 @@ void lokit_main(const std::string& childRoot,
std::string message(data.data(), data.size());
if (UnitKit::get().filterKitMessage(ws, message))
+ {
return true;
+ }
LOG_DBG(socketName << ": recv [" << LOOLProtocol::getAbbreviatedMessage(message) << "].");
StringTokenizer tokens(message, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
diff --git a/loolwsd/LibreOfficeKit.hpp b/loolwsd/LibreOfficeKit.hpp
index 15108ec..cab4cbe 100644
--- a/loolwsd/LibreOfficeKit.hpp
+++ b/loolwsd/LibreOfficeKit.hpp
@@ -512,7 +512,14 @@ public:
{
std::unique_lock<std::mutex> lock(_mutex);
Log::trace("lok::~Office dtor.");
- _pOffice->pClass->destroy(_pOffice);
+ try
+ {
+ _pOffice->pClass->destroy(_pOffice);
+ }
+ catch (const std::exception& ex)
+ {
+ LOG_ERR("Exception while destroying LibreOfficeKit instance: " << ex.what());
+ }
}
/// This lock must be held while calling
More information about the Libreoffice-commits
mailing list