<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Feb 9, 2015 at 12:35 PM, Ben Langmuir <span dir="ltr"><<a href="mailto:blangmuir@apple.com" target="_blank">blangmuir@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: benlangmuir<br>
Date: Mon Feb  9 14:35:13 2015<br>
New Revision: 228604<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=228604&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=228604&view=rev</a><br>
Log:<br>
Diagnose timeouts in the LockFileManager and delete the dead lock file<br>
<br>
If the lock file manager times out, we should give an error rather than<br>
silently trying to load the existing module.  And delete the<br>
(presumably) dead lock file, since it will otherwise prevent progress in<br>
future invokations. This is unsound since we have no way to prove that<br>
the lock file we are deleting is the same one we timed out on, but since<br>
the lock is only to avoid excessive rebuilding anyway it should be okay.<br>
Depends on llvm r228603.<br></blockquote><div><br></div><div>This diagnostic fires a *lot* when, say, bootstrapping Clang with modules enabled at -j16. Is the timeout perhaps too short?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Modified:<br>
    cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td<br>
    cfe/trunk/lib/Frontend/CompilerInstance.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=228604&r1=228603&r2=228604&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=228604&r1=228603&r2=228604&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Mon Feb  9 14:35:13 2015<br>
@@ -83,6 +83,8 @@ def err_module_not_found : Error<"module<br>
 def err_module_not_built : Error<"could not build module '%0'">, DefaultFatal;<br>
 def err_module_lock_failure : Error<<br>
   "could not acquire lock file for module '%0'">, DefaultFatal;<br>
+def err_module_lock_timeout : Error<<br>
+  "timed out waiting to acquire lock file for module '%0'">, DefaultFatal;<br>
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">,<br>
   DefaultFatal;<br>
 def note_pragma_entered_here : Note<"#pragma entered here">;<br>
<br>
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=228604&r1=228603&r2=228604&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=228604&r1=228603&r2=228604&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Feb  9 14:35:13 2015<br>
@@ -1022,9 +1022,19 @@ static bool compileAndLoadModule(Compile<br>
     case llvm::LockFileManager::LFS_Shared:<br>
       // Someone else is responsible for building the module. Wait for them to<br>
       // finish.<br>
-      if (Locked.waitForUnlock() == llvm::LockFileManager::Res_OwnerDied)<br>
+      switch (Locked.waitForUnlock()) {<br>
+      case llvm::LockFileManager::Res_Success:<br>
+        ModuleLoadCapabilities |= ASTReader::ARR_OutOfDate;<br>
+        break;<br>
+      case llvm::LockFileManager::Res_OwnerDied:<br>
         continue; // try again to get the lock.<br>
-      ModuleLoadCapabilities |= ASTReader::ARR_OutOfDate;<br>
+      case llvm::LockFileManager::Res_Timeout:<br>
+        Diags.Report(ModuleNameLoc, diag::err_module_lock_timeout)<br>
+            << Module->Name;<br>
+        // Clear the lock file so that future invokations can make progress.<br>
+        Locked.unsafeRemoveLockFile();<br>
+        return false;<br>
+      }<br>
       break;<br>
     }<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>