[llvm] r328300 - [ORC] Join materialization thread in unit test

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 23 03:14:20 PDT 2018


Author: d0k
Date: Fri Mar 23 03:14:19 2018
New Revision: 328300

URL: http://llvm.org/viewvc/llvm-project?rev=328300&view=rev
Log:
[ORC] Join materialization thread in unit test

There's are race between this thread and the destructor of the test ORC
components on the main threads. I saw flaky failures there in about 4%
of the runs of this unit test.

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

Modified: llvm/trunk/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp?rev=328300&r1=328299&r2=328300&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp Fri Mar 23 03:14:19 2018
@@ -392,15 +392,15 @@ TEST(CoreAPIsTest, TestLookupWithThreade
 
   ExecutionSession ES(SSP);
 
-  auto MaterializeOnNewThread = [&ES](VSO &V,
-                                      std::unique_ptr<MaterializationUnit> MU) {
+  std::thread MaterializationThread;
+  auto MaterializeOnNewThread = [&](VSO &V,
+                                    std::unique_ptr<MaterializationUnit> MU) {
     // FIXME: Use move capture once we move to C++14.
     std::shared_ptr<MaterializationUnit> SharedMU = std::move(MU);
-    std::thread([&ES, &V, SharedMU]() {
+    MaterializationThread = std::thread([&ES, &V, SharedMU]() {
       if (auto Err = SharedMU->materialize(V))
         ES.reportError(std::move(Err));
-    })
-        .detach();
+    });
   };
 
   auto FooLookupResult =
@@ -410,6 +410,7 @@ TEST(CoreAPIsTest, TestLookupWithThreade
       << "lookup returned an incorrect address";
   EXPECT_EQ(FooLookupResult.getFlags(), FooSym.getFlags())
       << "lookup returned incorrect flags";
+  MaterializationThread.join();
 #endif
 }
 




More information about the llvm-commits mailing list