[PATCH] D30107: Refactor DynamicLibrary so searching for a symbol will have a defined order and libraries are properly unloaded when llvm_shutdown is called.

Frederich Munch via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 12:15:40 PDT 2017


marsupial added inline comments.


================
Comment at: llvm/trunk/include/llvm/Support/DynamicLibrary.h:61
     /// This function permanently loads the dynamic library at the given path.
-    /// The library will only be unloaded when the program terminates.
+    /// The library will only be unloaded when llvm_shutdown() is called.
     /// This returns a valid DynamicLibrary instance on success and an invalid
----------------
efriedma wrote:
> Is this change necessary?  I don't see any discussion of this in the review.
> 
> In addition to being used by the JIT, this API is used to load plugins, and unloading a plugin during llvm_shutdown() can cause a segfault, depending on the order globals get destroyed.
I can see the benefit of DynamicLibrary::HandleSet::~HandleSet iterating in reverse order, but having LLVM release memory when I explicitly tell it I'm not using LLVM anymore is important.

Not releasing / deallocating the libraries seems to be a violation of the documentation:
"When you are done using the LLVM APIs, you should call llvm_shutdown() to deallocate memory used for internal structures."

If there are issues with plugins wouldn't it better handled in the plugin interface with a way to signal shutdown will/is occurring.


Repository:
  rL LLVM

https://reviews.llvm.org/D30107





More information about the llvm-commits mailing list