mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-17 18:31:04 +00:00
Fix PR8441, a thread unsafe static variable in our dynamic library loading facilities.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118463 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5e559a22c1
commit
9ac18d562d
@ -15,6 +15,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/System/DynamicLibrary.h"
|
||||
#include "llvm/System/Mutex.h"
|
||||
#include "llvm/Config/config.h"
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
@ -60,6 +61,7 @@ using namespace llvm::sys;
|
||||
//=== independent code.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
static SmartMutex<true> HandlesMutex;
|
||||
static std::vector<void *> *OpenedHandles = 0;
|
||||
|
||||
|
||||
@ -76,6 +78,7 @@ bool DynamicLibrary::LoadLibraryPermanently(const char *Filename,
|
||||
if (Filename == NULL)
|
||||
H = RTLD_DEFAULT;
|
||||
#endif
|
||||
SmartScopedLock<true> Lock(HandlesMutex);
|
||||
if (OpenedHandles == 0)
|
||||
OpenedHandles = new std::vector<void *>();
|
||||
OpenedHandles->push_back(H);
|
||||
@ -110,6 +113,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) {
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
// Now search the libraries.
|
||||
SmartScopedLock<true> Lock(HandlesMutex);
|
||||
if (OpenedHandles) {
|
||||
for (std::vector<void *>::iterator I = OpenedHandles->begin(),
|
||||
E = OpenedHandles->end(); I != E; ++I) {
|
||||
|
Loading…
Reference in New Issue
Block a user