[PATCH] D33652: Close DynamicLibraries in reverse order they were opened.
Frederich Munch via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 29 11:14:14 PDT 2017
marsupial created this revision.
Matches C++ destruction ordering better and fixes possible problems of loaded libraries having inter-dependencies.
https://reviews.llvm.org/D33652
Files:
lib/Support/DynamicLibrary.cpp
lib/Support/Unix/DynamicLibrary.inc
lib/Support/Windows/DynamicLibrary.inc
Index: lib/Support/Windows/DynamicLibrary.inc
===================================================================
--- lib/Support/Windows/DynamicLibrary.inc
+++ lib/Support/Windows/DynamicLibrary.inc
@@ -23,7 +23,7 @@
DynamicLibrary::HandleSet::~HandleSet() {
- for (void *Handle : Handles)
+ for (void *Handle : llvm::reverse_range(Handles))
FreeLibrary(HMODULE(Handle));
// 'Process' should not be released on Windows.
Index: lib/Support/Unix/DynamicLibrary.inc
===================================================================
--- lib/Support/Unix/DynamicLibrary.inc
+++ lib/Support/Unix/DynamicLibrary.inc
@@ -15,7 +15,8 @@
#include <dlfcn.h>
DynamicLibrary::HandleSet::~HandleSet() {
- for (void *Handle : Handles)
+ // Close the libraries in reverse order.
+ for (void *Handle : llvm::reverse_range(Handles))
::dlclose(Handle);
if (Process)
::dlclose(Process);
Index: lib/Support/DynamicLibrary.cpp
===================================================================
--- lib/Support/DynamicLibrary.cpp
+++ lib/Support/DynamicLibrary.cpp
@@ -14,6 +14,7 @@
#include "llvm/Support/DynamicLibrary.h"
#include "llvm-c/Support.h"
#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Config/config.h"
#include "llvm/Support/ManagedStatic.h"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33652.100628.patch
Type: text/x-patch
Size: 1348 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170529/961daaa6/attachment.bin>
More information about the llvm-commits
mailing list