[llvm-dev] Newly added ThreadPoolExecutor causes deadlock in lld

Evgeny Leviant via llvm-dev llvm-dev at lists.llvm.org
Fri Oct 6 10:09:45 PDT 2017


Recently added ThreadPoolExecutor limits number of worker threads to number of logical processors.

This might cause deadlock in case one's doing nested calls to parallel_for_each, like this:


void Bar() { ... }


void Foo() {

    parallel_for_each(Begin, End, Bar);

}


void main() {

  parallel_for_each(Begin, End, Foo);

}


This happens because both parallel_for_each and parallel_for_each_n wait for task group to finish

and this may actually never happen in case they're executed from worker threads. In such case worker

thread is blocked in TaskGroup destructor. This does happen in lld, when it writes output sections as

there is a nested call to parallel_for_each_n to write each output section inputs.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171006/2690526c/attachment.html>


More information about the llvm-dev mailing list