[PATCH] D32826: Move Parallel.h from LLD to LLVM

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 3 13:32:05 PDT 2017


labath added inline comments.


================
Comment at: llvm/include/llvm/Support/Parallel.h:125
+      for (size_t i = 1; i < threadCount; ++i) {
+        std::thread([=] { work(); }).detach();
+      }
----------------
There's a somewhat annoying bug <https://sourceware.org/bugzilla/show_bug.cgi?id=19951> present in all versions of glibc, which can lead to crashes if the thread happens to exit while it is being detached. I see no synchronization here which would prevent that, so I guess whether the crash happens depends on the type of work we will do here.

The workaround is to add some synchronization which makes sure these two things don't happen concurrently (adds some overhead, but if done right it can be negligible), or create the threads in a detached state (impossible through the std::thread API).


https://reviews.llvm.org/D32826





More information about the llvm-commits mailing list