diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-03-11 00:44:21 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-03-11 10:08:06 +0000 |
commit | 9899ffd244dd367ba69dffe1f21f4f0222064a46 (patch) | |
tree | 5b0a076e2216e9e189b811ce2fcffc23af5910e5 /package | |
parent | tdf#106217: Wrong size and position of a shape inside chart (diff) | |
download | core-9899ffd244dd367ba69dffe1f21f4f0222064a46.tar.gz core-9899ffd244dd367ba69dffe1f21f4f0222064a46.zip |
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] http://support.microsoft.com/kb/2582203
[2] https://msdn.microsoft.com/en-US/library/windows/desktop/ms682583(v=vs.85).aspx
[3] https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx
[4] https://blogs.msdn.microsoft.com/oldnewthing/20100827-00/?p=13023
Change-Id: I6137461ca7efe9a5fbe4f8f8478fb96de3570469
Reviewed-on: https://gerrit.libreoffice.org/35066
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'package')
-rw-r--r-- | package/qa/cppunit/test_package.cxx | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/package/qa/cppunit/test_package.cxx b/package/qa/cppunit/test_package.cxx index 335f490ddaba..d015e8db8d66 100644 --- a/package/qa/cppunit/test_package.cxx +++ b/package/qa/cppunit/test_package.cxx @@ -119,8 +119,16 @@ namespace uno::Reference<container::XNameAccess> xNA(xZip, uno::UNO_QUERY); CPPUNIT_ASSERT(xNA.is()); + struct TestThreadPool { - comphelper::ThreadPool aPool(4); + comphelper::ThreadPool aPool; + TestThreadPool(sal_Int32 const i) : aPool(i) {} + ~TestThreadPool() { aPool.shutdown(); } + }; + + { + TestThreadPool aPool(4); + comphelper::ThreadPool & rPool(aPool.aPool); std::shared_ptr<comphelper::ThreadTaskTag> pTag = comphelper::ThreadPool::createThreadTaskTag(); std::vector<std::vector<char>> aTestBuffers(26); @@ -135,10 +143,10 @@ namespace xNA->getByName(aName) >>= xStrm; CPPUNIT_ASSERT(xStrm.is()); - aPool.pushTask(new Worker(pTag, xStrm, *itBuf)); + rPool.pushTask(new Worker(pTag, xStrm, *itBuf)); } - aPool.waitUntilDone(pTag); + rPool.waitUntilDone(pTag); // Verify the streams. CPPUNIT_ASSERT_EQUAL(size_t(26), aTestBuffers.size()); |