[PATCH] D33581: Fix the ManagedStatic list ordering when using DynamicLibrary::addPermanentLibrary.

Frederich Munch via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 26 12:43:48 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL304027: Fix the ManagedStatic list ordering when using DynamicLibrary… (authored by marsupial).

Changed prior to commit:
  https://reviews.llvm.org/D33581?vs=100353&id=100454#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33581

Files:
  llvm/trunk/lib/Support/DynamicLibrary.cpp


Index: llvm/trunk/lib/Support/DynamicLibrary.cpp
===================================================================
--- llvm/trunk/lib/Support/DynamicLibrary.cpp
+++ llvm/trunk/lib/Support/DynamicLibrary.cpp
@@ -127,10 +127,15 @@
 
 DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *FileName,
                                                    std::string *Err) {
-  SmartScopedLock<true> Lock(*SymbolsMutex);
+  // Force OpenedHandles to be added into the ManagedStatic list before any
+  // ManagedStatic can be added from static constructors in HandleSet::DLOpen.
+  HandleSet& HS = *OpenedHandles;
+
   void *Handle = HandleSet::DLOpen(FileName, Err);
-  if (Handle != &Invalid)
-    OpenedHandles->AddLibrary(Handle, /*IsProcess*/ FileName == nullptr);
+  if (Handle != &Invalid) {
+    SmartScopedLock<true> Lock(*SymbolsMutex);
+    HS.AddLibrary(Handle, /*IsProcess*/ FileName == nullptr);
+  }
 
   return DynamicLibrary(Handle);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33581.100454.patch
Type: text/x-patch
Size: 957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170526/ac2fe4c7/attachment.bin>


More information about the llvm-commits mailing list