[llvm] [Support] Join threads when stopping the ThreadPoolExecutor (PR #166054)

Maurice Heumann via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 3 09:39:43 PST 2025


momo5502 wrote:

> Just want to note that IIRC, the reason for only joining the threads in the destructor was to speed up "fast" no cleanup exit, i.e. would skip joining any threads. This used to be quite an overhead for systems with very high thread counts. Something to bear in mind.

I understand. However, I would argue that this is dangerous. On Windows, the OS kills all threads before calling the destructors of the main exe. So in case any thread held a lock, this might cause deadlocks as well, just like in the DLL case here.
The safest thing to do would always be to join the threads before calling the destructors. 



https://github.com/llvm/llvm-project/pull/166054


More information about the llvm-commits mailing list