[lldb/Platform] Synchronize access to SDK String Map.
authorJonas Devlieghere <jonas@devlieghere.com>
Wed, 29 Apr 2020 02:20:06 +0000 (19:20 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Wed, 29 Apr 2020 02:21:58 +0000 (19:21 -0700)
The SwiftASTContext queries this function in parallel and requires
synchronization.

lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h

index 5252d37..6a00afb 100644 (file)
@@ -1762,6 +1762,7 @@ PlatformDarwin::FindXcodeContentsDirectoryInPath(llvm::StringRef path) {
 }
 
 std::string PlatformDarwin::GetSDKPath(XcodeSDK sdk) {
+  std::lock_guard<std::mutex> guard(m_sdk_path_mutex);
   std::string &path = m_sdk_path[sdk.GetString()];
   if (!path.empty())
     return path;
index d3b4181..e4f7173 100644 (file)
@@ -171,6 +171,7 @@ protected:
 
   std::string m_developer_directory;
   llvm::StringMap<std::string> m_sdk_path;
+  std::mutex m_sdk_path_mutex;
 
 private:
   DISALLOW_COPY_AND_ASSIGN(PlatformDarwin);