[PATCH] D72090: [Support] Fix race during thread pool teardown

David Zarzycki via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 2 09:30:49 PST 2020


davezarzycki created this revision.
davezarzycki added a reviewer: zturner.
davezarzycki added a project: LLVM.
Herald added a subscriber: hiraditya.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72090

Files:
  llvm/lib/Support/Parallel.cpp


Index: llvm/lib/Support/Parallel.cpp
===================================================================
--- llvm/lib/Support/Parallel.cpp
+++ llvm/lib/Support/Parallel.cpp
@@ -53,7 +53,9 @@
     Stop = true;
     Lock.unlock();
     Cond.notify_all();
-    // Wait for ~Latch.
+    // Explicitly wait threads to complete, otherwise the instance variables of
+    // this class can be prematurely destroyed.
+    Done.sync();
   }
 
   void add(std::function<void()> F) override {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72090.235895.patch
Type: text/x-patch
Size: 481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200102/35f09109/attachment.bin>


More information about the llvm-commits mailing list