[Lldb-commits] [lldb] r266423 - Work around a linux libc bug causing a crash in TaskPool
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 15 03:49:07 PDT 2016
Author: labath
Date: Fri Apr 15 05:49:07 2016
New Revision: 266423
URL: http://llvm.org/viewvc/llvm-project?rev=266423&view=rev
Log:
Work around a linux libc bug causing a crash in TaskPool
Summary:
Doing a pthread_detach while the thread is exiting can cause crashes or other mischief, so we
make sure the thread stays around long enough. The performance impact of the added
synchronization should be minimal, as the parent thread is already holding a mutex, so I am just
making sure it holds it for a little while longer. It's possible the new thread will block on
this mutex immediately after startup, but it should be unblocked really quickly and some
blocking is unavoidable if we actually want to have this synchronization.
Reviewers: tberghammer
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D19153
Modified:
lldb/trunk/source/Utility/TaskPool.cpp
Modified: lldb/trunk/source/Utility/TaskPool.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/TaskPool.cpp?rev=266423&r1=266422&r2=266423&view=diff
==============================================================================
--- lldb/trunk/source/Utility/TaskPool.cpp (original)
+++ lldb/trunk/source/Utility/TaskPool.cpp Fri Apr 15 05:49:07 2016
@@ -61,8 +61,9 @@ TaskPoolImpl::AddTask(std::function<void
if (m_thread_count < max_threads)
{
m_thread_count++;
- lock.unlock();
-
+ // Note that this detach call needs to happen with the m_tasks_mutex held. This prevents the thread
+ // from exiting prematurely and triggering a linux libc bug
+ // (https://sourceware.org/bugzilla/show_bug.cgi?id=19951).
std::thread (Worker, this).detach();
}
}
More information about the lldb-commits
mailing list