[PATCH] D29955: Allow externally dlopen-ed libraries to be registered as permanent libraries.

Vassil Vassilev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 20 12:54:33 PST 2017


v.g.vassilev marked 2 inline comments as done.
v.g.vassilev added inline comments.


================
Comment at: lib/Support/DynamicLibrary.cpp:74
+DynamicLibrary DynamicLibrary::addPermanentLibrary(void *handle) {
+  SmartScopedLock<true> lock(*SymbolsMutex);
 
----------------
vsk wrote:
> v.g.vassilev wrote:
> > vsk wrote:
> > > Is there a double-lock scenario here? getPermanentLibrary() would lock, then addPermanentLibrary() would lock again?
> > Yeah, I am not sure how to avoid this...
> Maybe std::lock_guard would be a good solution. I.e add an API to grab a std::lock_guard from the DynamicLibrary class, then require the lock_guard to be moved into addPermanentLibrary.
It seems the locking should protect only dlerror. I decided to lock around dlopen/dlclose because I found some bug reports of them not being thread safe on some implementations.


https://reviews.llvm.org/D29955





More information about the llvm-commits mailing list