From 9b0a69d6dc741d960d739f4e660a820a868fb2b0 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 20 May 2014 23:05:09 +0000 Subject: [PATCH] [PECOFF] Acquire mutex before accessing shared objects. addResolvableSymbols() queues input files, and readAllSymbols() reads from them. In practice it's currently safe because they are called from a single thread. But it's not guaranteed. Also, acquiring the same mutex is needed not to see inconsistent memory contents that is allowed in the C++ memory model. llvm-svn: 209254 --- lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h b/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h index 29faa39..68b696e 100644 --- a/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h +++ b/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h @@ -219,6 +219,7 @@ private: // Files are read lazily, so that it has no runtime overhead if // there's no dllexported stdcall functions. void readAllSymbols() const { + std::lock_guard lock(_mutex); for (File *file : _queue) { if (auto *archive = dyn_cast(file)) { for (const std::string &sym : archive->getDefinedSymbols()) -- 2.7.4