COFF: Fix thread-safety bug.
LTOModule doesn't seem to be thread-safe, so guard that with mutex. llvm-svn: 248102
This commit is contained in:
parent
1e63b2bdc3
commit
ebb0ebff4b
|
@ -310,6 +310,9 @@ void ImportFile::parse() {
|
|||
}
|
||||
|
||||
void BitcodeFile::parse() {
|
||||
// Usually parse() is thread-safe, but bitcode file is an exception.
|
||||
std::lock_guard<std::mutex> Lock(Mu);
|
||||
|
||||
std::string Err;
|
||||
M.reset(LTOModule::createFromBuffer(MB.getBufferStart(),
|
||||
MB.getBufferSize(),
|
||||
|
@ -356,5 +359,7 @@ MachineTypes BitcodeFile::getMachineType() {
|
|||
}
|
||||
}
|
||||
|
||||
std::mutex BitcodeFile::Mu;
|
||||
|
||||
} // namespace coff
|
||||
} // namespace lld
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "llvm/Object/COFF.h"
|
||||
#include "llvm/Support/StringSaver.h"
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
|
@ -213,6 +214,7 @@ private:
|
|||
std::vector<SymbolBody *> SymbolBodies;
|
||||
llvm::BumpPtrAllocator Alloc;
|
||||
std::unique_ptr<LTOModule> M;
|
||||
static std::mutex Mu;
|
||||
};
|
||||
|
||||
} // namespace coff
|
||||
|
|
Loading…
Reference in New Issue