[PATCH] D33515: Fix the ManagedStatic list ordering when using DynamicLibrary::addPermanentLibrary.
Frederich Munch via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 24 13:29:19 PDT 2017
marsupial created this revision.
r295737 included a fix for leaking libraries loaded via. DynamicLibrary::addPermanentLibrary.
This created a problem where static constructors in a library could insert llvm::ManagedStatic objects before DynamicLibrary would register it's own ManagedStatic, meaning a crash could occur at shutdown.
r301562 exasperated this problem by cleaning up the DynamicLibrary ManagedStatic during llvm_shutdown.
https://reviews.llvm.org/D33515
Files:
lib/Support/DynamicLibrary.cpp
Index: lib/Support/DynamicLibrary.cpp
===================================================================
--- lib/Support/DynamicLibrary.cpp
+++ lib/Support/DynamicLibrary.cpp
@@ -128,9 +128,14 @@
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);
+ HS.AddLibrary(Handle, /*IsProcess*/ FileName == nullptr);
return DynamicLibrary(Handle);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33515.100153.patch
Type: text/x-patch
Size: 841 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170524/1c32bc63/attachment.bin>
More information about the llvm-commits
mailing list