Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make DynamicLibrary thread-safe w/r/t call to dlerror() after dlopen(…

…). PR10718

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138260 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information...
commit eeb37f1a568185c46f600fb34769ec376bf5bfaf 1 parent 11e03e7
@belkadan belkadan authored
View
3  lib/Support/DynamicLibrary.cpp
@@ -72,6 +72,8 @@ static DenseSet<void *> *OpenedHandles = 0;
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 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
handle = RTLD_DEFAULT;
#endif
- SmartScopedLock<true> lock(getMutex());
if (OpenedHandles == 0)
OpenedHandles = new DenseSet<void *>();
View
4 lib/Support/Windows/DynamicLibrary.inc
@@ -71,9 +71,10 @@ extern "C" {
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 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
return DynamicLibrary();
}
- SmartScopedLock<true> lock(getMutex());
if (OpenedHandles == 0)
OpenedHandles = new DenseSet<HMODULE>();
Please sign in to comment.
Something went wrong with that request. Please try again.