[llvm] 195c816 - ORC: Fix flaky OrcLazy tests (#228619)

via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 3 00:15:43 PDT 2026


Author: Matt Arsenault
Date: 2026-10-03T17:15:36+10:00
New Revision: 195c81658995a4b7531c30a12c5aef6cf2bbd671

URL: https://github.com/llvm/llvm-project/commit/195c81658995a4b7531c30a12c5aef6cf2bbd671
DIFF: https://github.com/llvm/llvm-project/commit/195c81658995a4b7531c30a12c5aef6cf2bbd671.diff

LOG: ORC: Fix flaky OrcLazy tests (#228619)

I've seen this fail a few too many times so just let AI deal with it. I
don't
know anything about orc, but extending lifetime of lock_guard seems
plausible.

Notify lookupInitSymbols CV while holding the mutex

The init-symbol lookup completion callback decremented Count under
LookupMutex but called CV.notify_one() after releasing it. The waiting
thread could observe Count == 0, return from lookupInitSymbols, and
destroy the stack-allocated mutex and condition variable before the
callback signalled it. With concurrent compile threads the callback runs
on a dispatcher thread, so the late notify wrote into reused stack
memory, e.g. during endSession right after deinitialize.

This caused intermittent crashes in
ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll on macOS
(#50408, #126982). MachOPlatform and ELFNixPlatform already notify their
bootstrap condition variables under the mutex for the same reason.

Co-authored-by: Claude
[noreply at anthropic.com](mailto:noreply at anthropic.com)

Co-authored-by: Claude <noreply at anthropic.com>

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/Orc/Core.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp
index b026addd5b083..da434e55ce4d1 100644
--- a/llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -1462,16 +1462,15 @@ Expected<DenseMap<JITDylib *, SymbolMap>> Platform::lookupInitSymbols(
         JITDylibSearchOrder({{JD, JITDylibLookupFlags::MatchAllSymbols}}),
         std::move(Names), SymbolState::Ready,
         [&, JD](Expected<SymbolMap> Result) {
-          {
-            std::lock_guard<std::mutex> Lock(LookupMutex);
-            --Count;
-            if (Result) {
-              assert(!CompoundResult.count(JD) &&
-                     "Duplicate JITDylib in lookup?");
-              CompoundResult[JD] = std::move(*Result);
-            } else
-              CompoundErr =
-                  joinErrors(std::move(CompoundErr), Result.takeError());
+          std::lock_guard<std::mutex> Lock(LookupMutex);
+          --Count;
+          if (Result) {
+            assert(!CompoundResult.count(JD) &&
+                   "Duplicate JITDylib in lookup?");
+            CompoundResult[JD] = std::move(*Result);
+          } else {
+            CompoundErr =
+                joinErrors(std::move(CompoundErr), Result.takeError());
           }
           CV.notify_one();
         },


        


More information about the llvm-commits mailing list