path: root/test/source
diff options
authorMichael Stahl <>2017-03-11 00:44:21 +0100
committerMichael Stahl <>2017-03-11 10:08:06 +0000
commit9899ffd244dd367ba69dffe1f21f4f0222064a46 (patch)
tree5b0a076e2216e9e189b811ce2fcffc23af5910e5 /test/source
parentaa204f1c09a760d6753c408376ab7307fb13ad91 (diff)
comphelper: fix MSVC hang in ThreadPool::shutdown()
Commit aa68c99d88fd7abe08c4aee5206c859a0cdba38e added some code using std::condition_variable to comphelper. Built with MSVC 2017, this causes many cppunittester.exe processes to deadlock in ThreadPool::shutdown(): maTasksChanged.notify_all(); This ultimately calls NtReleaseKeyedEvent(), which never returns. The reason appears to be a bug in Windows 7, for which a "hotfix"[1] is avaiable here, but it's apparently not distributed via Windows Update so we likely can't rely on users or even developers having this installed. However, the documentation of DllMain[2] and ExitProcess[3] indicates that during shutdown, by the time global destructors are invoked all threads other than the one that called ExitProcess have already been terminated. Returning from main() implicitly calls ExitProcess [4]. As it turns out the problem only happens for some CppUnitTests because soffice.bin will call ThreadPool::shutdown() from Desktop::doShutdown() while it is still safe. [1] [2] [3] [4] Change-Id: I6137461ca7efe9a5fbe4f8f8478fb96de3570469 Reviewed-on: Tested-by: Jenkins <> Reviewed-by: Michael Stahl <>
Diffstat (limited to 'test/source')
2 files changed, 10 insertions, 0 deletions
diff --git a/test/source/bootstrapfixture.cxx b/test/source/bootstrapfixture.cxx
index c97c0ceed535..5fa01a388c50 100644
--- a/test/source/bootstrapfixture.cxx
+++ b/test/source/bootstrapfixture.cxx
@@ -16,6 +16,7 @@
#include <rtl/bootstrap.hxx>
#include <cppuhelper/bootstrap.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/threadpool.hxx>
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/lang/XComponent.hpp>
@@ -97,6 +98,12 @@ SAL_DLLPUBLIC_EXPORT void test_init(lang::XMultiServiceFactory *pFactory)
catch (...) { abort(); }
+// this is called from pyuno
+SAL_DLLPUBLIC_EXPORT void test_fini()
+ ::comphelper::ThreadPool::getSharedOptimalPool().shutdown();
} // extern "C"
void test::BootstrapFixture::setUp()
diff --git a/test/source/vclbootstrapprotector.cxx b/test/source/vclbootstrapprotector.cxx
index 38c51d990922..2218c8fff2c0 100644
--- a/test/source/vclbootstrapprotector.cxx
+++ b/test/source/vclbootstrapprotector.cxx
@@ -14,6 +14,7 @@
#include <sal/types.h>
#include <test/setupvcl.hxx>
#include <vcl/svapp.hxx>
+#include <comphelper/threadpool.hxx>
#include <isheadless.hxx>
@@ -28,6 +29,8 @@ public:
virtual ~Protector() override {
+ // for the 6 tests that use it
+ comphelper::ThreadPool::getSharedOptimalPool().shutdown();
virtual bool protect(