diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-09-21 14:03:14 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-09-21 15:26:05 +0200 |
commit | 43d08f386117cbeeee1de1fe2ba8248554c1aef1 (patch) | |
tree | b47c6ee219ee1349520e69cee4d7acd7220ce12f /sal | |
parent | fec332602976676e1689a45ed846488f2484c89e (diff) |
cppunittester: Do not unload test libraries
At least on Windows, e6dfaf9f44f9939abc338c83b3024108431d0f69 "Turn
OUStringLiteral into a consteval'ed, static-refcound rtl_uString" caused
CppunitTest_sc_tablesheetsobj to fail at exit, when the
static OUString aCacheName
in ScDocument::GetTable (sc/source/core/data/document.cxx) is destroyed but
references
constexpr OUStringLiteral gaSrcSheetName(u"SheetToCopy")
from test/source/sheet/xspreadsheets2.cxx in Library_subsequenttest, referenced
(only) by the CppunitTest_sc_tablesheetsobj library, and both those libraries
had already been unloaded from memory.
Change-Id: Icea85019611fbaec3603f37b234e9e6fe3502961
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103103
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/cppunittester/cppunittester.cxx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx index a760ecf8ff41..0a833de5fba2 100644 --- a/sal/cppunittester/cppunittester.cxx +++ b/sal/cppunittester/cppunittester.cxx @@ -254,9 +254,14 @@ public: // call the initialize methods of the CppUnitTestPlugIns that // we statically link to the app executable. #else - CppUnit::PlugInManager manager; + // The PlugInManager instance is deliberately leaked, so that the dynamic libraries it loads + // are never unloaded (which could make e.g. pointers from other libraries' static data + // structures to const data in those libraries, like some static OUString cache pointing at + // a const OUStringLiteral, become dangling by the time those static data structures are + // destroyed during exit): + auto manager = new CppUnit::PlugInManager; try { - manager.load(testlib, args); + manager->load(testlib, args); } catch (const CppUnit::DynamicLibraryManagerException &e) { std::cerr << "DynamicLibraryManagerException: \"" << e.what() << "\"\n"; #ifdef _WIN32 |