[Lldb-commits] [lldb] r169612 - /lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
Jim Ingham
jingham at apple.com
Fri Dec 7 09:42:15 PST 2012
Author: jingham
Date: Fri Dec 7 11:42:15 2012
New Revision: 169612
URL: http://llvm.org/viewvc/llvm-project?rev=169612&view=rev
Log:
Take the Target API lock before letting the Python code start to work constructing threads, otherwise we will risk a lock-inversion deadlock between the thread list and the API mutex.
<rdar://problem/12554049>
Modified:
lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
Modified: lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp?rev=169612&r1=169611&r2=169612&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp (original)
+++ lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp Fri Dec 7 11:42:15 2012
@@ -182,6 +182,12 @@
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+ // First thing we have to do is get the API lock, and the run lock. We're going to change the thread
+ // content of the process, and we're going to use python, which requires the API lock to do it.
+ // So get & hold that. This is a recursive lock so we can grant it to any Python code called on the stack below us.
+ Target &target = m_process->GetTarget();
+ Mutex::Locker api_locker (target.GetAPIMutex());
+
if (log)
log->Printf ("OperatingSystemPython::UpdateThreadList() fetching thread data from python for pid %" PRIu64, m_process->GetID());
@@ -251,6 +257,12 @@
if (!m_interpreter || !m_python_object || !thread)
return RegisterContextSP();
+ // First thing we have to do is get the API lock, and the run lock. We're going to change the thread
+ // content of the process, and we're going to use python, which requires the API lock to do it.
+ // So get & hold that. This is a recursive lock so we can grant it to any Python code called on the stack below us.
+ Target &target = m_process->GetTarget();
+ Mutex::Locker api_locker (target.GetAPIMutex());
+
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
if (reg_data_addr != LLDB_INVALID_ADDRESS)
More information about the lldb-commits
mailing list