[PATCH] D70447: [Support] ThreadPoolExecutor fixes for Windows/MinGW

Andrew Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 19 08:43:20 PST 2019


andrewng created this revision.
andrewng added reviewers: ruiu, zturner, thakis.
Herald added subscribers: mstorsjo, jfb, hiraditya.
Herald added a project: LLVM.

Changed ThreadPoolExecutor to no longer use detached threads and instead
to join threads on destruction. This is to prevent intermittent crashing
on Windows when doing a normal full exit, e.g. via exit().

Changed ThreadPoolExecutor to be a ManagedStatic so that it can be
stopped on llvm_shutdown(). Without this, it would only be stopped in
the destructor when doing a full exit. This is required to avoid
intermittent crashing on Windows due to a race condition between the
ThreadPoolExecutor starting up threads and the process doing a fast
exit, e.g. via _exit().

The Windows crashes appear to only occur with the MSVC static runtimes
and are more frequent with the debug static runtime.

These changes also prevent intermittent deadlocks on exit with the MinGW
runtime.


https://reviews.llvm.org/D70447

Files:
  llvm/lib/Support/Parallel.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70447.230080.patch
Type: text/x-patch
Size: 4007 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191119/da5eaa52/attachment.bin>


More information about the llvm-commits mailing list