From 7b26dbb1251bbbe8e96c1bcc5815426727aca53a Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Mon, 14 Nov 2016 23:45:50 +0000 Subject: [PATCH] Fix a deadlock issue that would happen when loading an AppleTV or watchOS binary. This was a regression that was caused by svn revision 269877: commit 1ded4a2a25d60dd2c81bd432bcf63b6ded58e5d6 Author: Saleem Abdulrasool Date: Wed May 18 01:59:10 2016 +0000 remove use of Mutex in favour of std::{,recursive_}mutex This is a pretty straightforward first pass over removing a number of uses of Mutex in favor of std::mutex or std::recursive_mutex. The problem is that there are interfaces which take Mutex::Locker & to lock internal locks. This patch cleans up most of the easy cases. The only non-trivial change is in CommandObjectTarget.cpp where a Mutex::Locker was split into two. git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@269877 91177308-0d34-0410-b5e6-96231b3b80d8 This change actually changed the Platform::m_mutex to be non-recursive which caused the regression. llvm-svn: 286908 --- lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp | 2 +- lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h | 1 + lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp | 1 + lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h | 1 + lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp | 1 + lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h | 1 + lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp | 1 + lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h | 1 + 8 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp index 8eb1a12..15d7e0c 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp @@ -263,7 +263,7 @@ EnumerateDirectoryCallback(void *baton, FileSpec::FileType file_type, } const char *PlatformAppleWatchSimulator::GetSDKDirectoryAsCString() { - std::lock_guard guard(m_mutex); + std::lock_guard guard(m_sdk_dir_mutex); if (m_sdk_directory.empty()) { const char *developer_dir = GetDeveloperDirectory(); if (developer_dir) { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h index d1b4ee5..2b15611 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h @@ -86,6 +86,7 @@ public: } protected: + std::mutex m_sdk_dir_mutex; std::string m_sdk_directory; std::string m_build_update; diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp index d62412f..5b09da2 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp @@ -258,6 +258,7 @@ PlatformRemoteAppleTV::GetContainedFilesIntoVectorOfStringsCallback( bool PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded() { Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); + std::lock_guard guard(m_sdk_dir_mutex); if (m_sdk_directory_infos.empty()) { const char *device_support_dir = GetDeviceSupportDirectory(); if (log) { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h index 2090e6a..388ea57 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h @@ -96,6 +96,7 @@ protected: bool user_cached; }; typedef std::vector SDKDirectoryInfoCollection; + std::mutex m_sdk_dir_mutex; SDKDirectoryInfoCollection m_sdk_directory_infos; std::string m_device_support_directory; std::string m_device_support_directory_for_os_version; diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp index b64aa62..c3e9ac5 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp @@ -268,6 +268,7 @@ PlatformRemoteAppleWatch::GetContainedFilesIntoVectorOfStringsCallback( bool PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded() { Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); + std::lock_guard guard(m_sdk_dir_mutex); if (m_sdk_directory_infos.empty()) { const char *device_support_dir = GetDeviceSupportDirectory(); if (log) { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h index d084a51..0b388af 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h @@ -98,6 +98,7 @@ protected: bool user_cached; }; typedef std::vector SDKDirectoryInfoCollection; + std::mutex m_sdk_dir_mutex; SDKDirectoryInfoCollection m_sdk_directory_infos; std::string m_device_support_directory; std::string m_device_support_directory_for_os_version; diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp index 0553b1b..ec88851 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp @@ -263,6 +263,7 @@ PlatformRemoteiOS::GetContainedFilesIntoVectorOfStringsCallback( bool PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded() { Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); + std::lock_guard guard(m_sdk_dir_mutex); if (m_sdk_directory_infos.empty()) { // A --sysroot option was supplied - add it to our list of SDKs to check if (m_sdk_sysroot) { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h index 7b7f27c..4d88a9e 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h @@ -94,6 +94,7 @@ protected: typedef std::vector SDKDirectoryInfoCollection; + std::mutex m_sdk_dir_mutex; SDKDirectoryInfoCollection m_sdk_directory_infos; std::string m_device_support_directory; std::string m_device_support_directory_for_os_version; -- 2.7.4