[PATCH] D18811: Fix a race condition in support library ThreadPool
Mehdi AMINI via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 6 14:56:37 PDT 2016
joker.eph added inline comments.
================
Comment at: lib/Support/ThreadPool.cpp:79
@@ -78,3 +70,3 @@
CompletionCondition.wait(LockGuard,
[&] { return Tasks.empty() && !ActiveThreads; });
}
----------------
jlebar wrote:
> joker.eph wrote:
> > Would just reversing the check solve the race?
> >
> > ```
> > [&] { return !ActiveThreads && Tasks.empty(); });
> > ```
> >
> > If not can you elaborate a little?
> >
> The race is that we touch Tasks here while holding only CompletionLock, while another thread in asyncImpl may touch Tasks while holding only QueueLock.
Mmmm the description of the revision was not about *enqueuing* like you suggest, but about poping.
I need another look then.
http://reviews.llvm.org/D18811
More information about the llvm-commits
mailing list