HomePhabricator

[Support] ThreadPoolExecutor fixes for Windows/MinGW

Authored by andrewng on Mar 16 2019, 12:36 PM.

Description

[Support] ThreadPoolExecutor fixes for Windows/MinGW

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.

Differential Revision: https://reviews.llvm.org/D70447

Details

Committed
andrewngJan 10 2020, 4:44 AM
Differential Revision
D70447: [Support] ThreadPoolExecutor fixes for Windows/MinGW
Parents
rGc88e298b6940: [lldb] Surpress "bitfield too small" gcc warning
Branches
Unknown
Tags
Unknown