[llvm] fda4300 - [ORC] Fix race condtition in CoreAPIsTest.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Fri May 21 21:13:15 PDT 2021


Author: Lang Hames
Date: 2021-05-21T21:11:54-07:00
New Revision: fda4300da8296ed831b3975a49f217a630045760

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

LOG: [ORC] Fix race condtition in CoreAPIsTest.

This test has been failing intermittently on some builders, probably due to a
race on the WorkThreads vector. This patch should fix that.

Added: 
    

Modified: 
    llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
index 8935ea4c3345..0dbbcb6f35d5 100644
--- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
@@ -1249,8 +1249,10 @@ TEST_F(CoreAPIsStandardTest, TestLookupWithUnthreadedMaterialization) {
 TEST_F(CoreAPIsStandardTest, TestLookupWithThreadedMaterialization) {
 #if LLVM_ENABLE_THREADS
 
+  std::mutex WorkThreadsMutex;
   std::vector<std::thread> WorkThreads;
   ES.setDispatchTask([&](std::unique_ptr<Task> T) {
+    std::lock_guard<std::mutex> Lock(WorkThreadsMutex);
     WorkThreads.push_back(
         std::thread([T = std::move(T)]() mutable { T->run(); }));
   });


        


More information about the llvm-commits mailing list