<div dir="ltr">I have no idea. CC'ing Peter since he may know about that.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 19, 2015 at 5:31 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Sat, Sep 19, 2015 at 4:14 PM, Rui Ueyama via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Sat Sep 19 18:14:51 2015<br>
New Revision: 248102<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=248102&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=248102&view=rev</a><br>
Log:<br>
COFF: Fix thread-safety bug.<br>
<br>
LTOModule doesn't seem to be thread-safe, so guard that with mutex.<br></blockquote><div><br></div></span><div>Yeah, that seems unfortunate.<br><br>Any idea where the thread unsafety comes from & whether we can/should fix it down the stack rather than in lld?</div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    lld/trunk/COFF/InputFiles.cpp<br>
    lld/trunk/COFF/InputFiles.h<br>
<br>
Modified: lld/trunk/COFF/InputFiles.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=248102&r1=248101&r2=248102&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=248102&r1=248101&r2=248102&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/COFF/InputFiles.cpp (original)<br>
+++ lld/trunk/COFF/InputFiles.cpp Sat Sep 19 18:14:51 2015<br>
@@ -310,6 +310,9 @@ void ImportFile::parse() {<br>
 }<br>
<br>
 void BitcodeFile::parse() {<br>
+  // Usually parse() is thread-safe, but bitcode file is an exception.<br>
+  std::lock_guard<std::mutex> Lock(Mu);<br>
+<br>
   std::string Err;<br>
   M.reset(LTOModule::createFromBuffer(MB.getBufferStart(),<br>
                                       MB.getBufferSize(),<br>
@@ -356,5 +359,7 @@ MachineTypes BitcodeFile::getMachineType<br>
   }<br>
 }<br>
<br>
+std::mutex BitcodeFile::Mu;<br>
+<br>
 } // namespace coff<br>
 } // namespace lld<br>
<br>
Modified: lld/trunk/COFF/InputFiles.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.h?rev=248102&r1=248101&r2=248102&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.h?rev=248102&r1=248101&r2=248102&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/COFF/InputFiles.h (original)<br>
+++ lld/trunk/COFF/InputFiles.h Sat Sep 19 18:14:51 2015<br>
@@ -17,6 +17,7 @@<br>
 #include "llvm/Object/COFF.h"<br>
 #include "llvm/Support/StringSaver.h"<br>
 #include <memory><br>
+#include <mutex><br>
 #include <set><br>
 #include <vector><br>
<br>
@@ -213,6 +214,7 @@ private:<br>
   std::vector<SymbolBody *> SymbolBodies;<br>
   llvm::BumpPtrAllocator Alloc;<br>
   std::unique_ptr<LTOModule> M;<br>
+  static std::mutex Mu;<br>
 };<br>
<br>
 } // namespace coff<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>