[Libreoffice-commits] core.git: sal/cppunittester
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Mon Sep 21 13:26:41 UTC 2020
sal/cppunittester/cppunittester.cxx | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
New commits:
commit 43d08f386117cbeeee1de1fe2ba8248554c1aef1
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Mon Sep 21 14:03:14 2020 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Mon Sep 21 15:26:05 2020 +0200
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 at redhat.com>
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
More information about the Libreoffice-commits
mailing list