PECOFF: Temporarily add a lock to un-break buildbot.
authorRui Ueyama <ruiu@google.com>
Fri, 20 Feb 2015 23:22:36 +0000 (23:22 +0000)
committerRui Ueyama <ruiu@google.com>
Fri, 20 Feb 2015 23:22:36 +0000 (23:22 +0000)
Looks like there's a threading issue in the COFF reader which makes
buildbot unstable. Probability of crash varies depending on the number
of input. If we are linking a big executalbe, LLD almost always crash.

This patch temporarily adds a lock to guard the reader so that LLD
doesn't crash. I'll investigate and fix the issue as soon as possible
because this patch has negative performance impact.

llvm-svn: 230086

lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp

index 27d26c8..9756fee 100644 (file)
@@ -307,6 +307,10 @@ StringRef getMachineName(llvm::COFF::MachineTypes Type) {
 }
 
 std::error_code FileCOFF::doParse() {
+  // Acquire a recursive lock because COFF file parsing has side effects.
+  // TODO: remove this lock as soon as possible after fixing threading issue.
+  std::lock_guard<std::recursive_mutex> lock(_ctx.getMutex());
+
   auto binaryOrErr = llvm::object::createBinary(_mb->getMemBufferRef());
   if (std::error_code ec = binaryOrErr.getError())
     return ec;