[lld] r209254 - [PECOFF] Acquire mutex before accessing shared objects.
Rui Ueyama
ruiu at google.com
Tue May 20 16:05:09 PDT 2014
Author: ruiu
Date: Tue May 20 18:05:09 2014
New Revision: 209254
URL: http://llvm.org/viewvc/llvm-project?rev=209254&view=rev
Log:
[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.
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h
Modified: lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h?rev=209254&r1=209253&r2=209254&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h Tue May 20 18:05:09 2014
@@ -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<std::mutex> lock(_mutex);
for (File *file : _queue) {
if (auto *archive = dyn_cast<ArchiveLibraryFile>(file)) {
for (const std::string &sym : archive->getDefinedSymbols())
More information about the llvm-commits
mailing list