[PATCH] D18811: Fix a race condition in support library ThreadPool
Jason Henline via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 6 15:25:14 PDT 2016
jhen added a comment.
To elaborate on the race condition, TSAN warns about the following when running the AsyncBarrier unit test (irrelevant stack frames removed):
WARNING: ThreadSanitizer: data race (pid=690669)
Read of size 8 at 0x7fff3627b2b8 by main thread (mutexes: write M1928):
wait<(lambda at lib/Support/ThreadPool.cpp:79:28)>
Previous write of size 8 at 0x7fff3627b2b8 by thread T5 (mutexes: write M1849):
operator() lib/Support/ThreadPool.cpp:53
So basically the wait routine can be checking whether the task queue is empty at the same time a thread can be trying to remove an element from the task queue. The queue data structure is not thread safe, so this is a race.
Sorry for the misleading description. I hope this clears up the issue.
http://reviews.llvm.org/D18811
More information about the llvm-commits
mailing list