[llvm-commits] [llvm] r138260 - in /llvm/trunk/lib/Support: DynamicLibrary.cpp Windows/DynamicLibrary.inc
Jordy Rose
jediknil at belkadan.com
Mon Aug 22 12:01:52 PDT 2011
Author: jrose
Date: Mon Aug 22 14:01:52 2011
New Revision: 138260
URL: http://llvm.org/viewvc/llvm-project?rev=138260&view=rev
Log:
Make DynamicLibrary thread-safe w/r/t call to dlerror() after dlopen(). PR10718
Modified:
llvm/trunk/lib/Support/DynamicLibrary.cpp
llvm/trunk/lib/Support/Windows/DynamicLibrary.inc
Modified: llvm/trunk/lib/Support/DynamicLibrary.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/DynamicLibrary.cpp?rev=138260&r1=138259&r2=138260&view=diff
==============================================================================
--- llvm/trunk/lib/Support/DynamicLibrary.cpp (original)
+++ llvm/trunk/lib/Support/DynamicLibrary.cpp Mon Aug 22 14:01:52 2011
@@ -72,6 +72,8 @@
DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
std::string *errMsg) {
+ SmartScopedLock<true> lock(getMutex());
+
void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL);
if (handle == 0) {
if (errMsg) *errMsg = dlerror();
@@ -85,7 +87,6 @@
handle = RTLD_DEFAULT;
#endif
- SmartScopedLock<true> lock(getMutex());
if (OpenedHandles == 0)
OpenedHandles = new DenseSet<void *>();
Modified: llvm/trunk/lib/Support/Windows/DynamicLibrary.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/DynamicLibrary.inc?rev=138260&r1=138259&r2=138260&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/DynamicLibrary.inc (original)
+++ llvm/trunk/lib/Support/Windows/DynamicLibrary.inc Mon Aug 22 14:01:52 2011
@@ -71,9 +71,10 @@
DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
std::string *errMsg) {
+ SmartScopedLock<true> lock(getMutex());
+
if (!filename) {
// When no file is specified, enumerate all DLLs and EXEs in the process.
- SmartScopedLock<true> lock(getMutex());
if (OpenedHandles == 0)
OpenedHandles = new DenseSet<HMODULE>();
@@ -90,7 +91,6 @@
return DynamicLibrary();
}
- SmartScopedLock<true> lock(getMutex());
if (OpenedHandles == 0)
OpenedHandles = new DenseSet<HMODULE>();
More information about the llvm-commits
mailing list