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
}
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;