From 198125a8ff9174b3f7fe38d7c031f3cc377f1884 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Thu, 28 Mar 2013 00:27:30 +0000 Subject: Holding the Python lock while we call the Python C API to post-process objects returned from the OS plugins This should avoid issues where some Python objects get invalidated while we are in the middle of processing them and we end up with an invalid Python state and a crash llvm-svn: 178206 --- lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp') diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp index 2f9c6987..c80b88c 100644 --- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -186,6 +186,7 @@ OperatingSystemPython::UpdateThreadList (ThreadList &old_thread_list, ThreadList if (log) log->Printf ("OperatingSystemPython::UpdateThreadList() fetching thread data from python for pid %" PRIu64, m_process->GetID()); + auto lock = m_interpreter->AcquireInterpreterLock(); // to make sure threads_list stays alive PythonList threads_list(m_interpreter->OSPlugin_ThreadsInfo(m_python_object_sp)); if (threads_list) { @@ -269,6 +270,7 @@ OperatingSystemPython::CreateRegisterContextForThread (Thread *thread, addr_t re Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD)); + auto lock = m_interpreter->AcquireInterpreterLock(); // to make sure python objects stays alive if (reg_data_addr != LLDB_INVALID_ADDRESS) { // The registers data is in contiguous memory, just create the register @@ -329,6 +331,7 @@ OperatingSystemPython::CreateThread (lldb::tid_t tid, addr_t context) Target &target = m_process->GetTarget(); Mutex::Locker api_locker (target.GetAPIMutex()); + auto lock = m_interpreter->AcquireInterpreterLock(); // to make sure thread_info_dict stays alive PythonDictionary thread_info_dict (m_interpreter->OSPlugin_CreateThread(m_python_object_sp, tid, context)); if (thread_info_dict) { -- cgit v1.1