[PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 1 16:56:14 PDT 2016


EricWF added a comment.

We can perform far fewer calls to `pthread_getspecific`/`pthread_setspecific` if we represent the list head using a global `__thread DtorList* list_head = nullptr`.
This also allows us to avoid the hack of setting/unsetting the key during `run_dtors()` which I really do not like.

Here is a patch that applies such changes: https://gist.github.com/EricWF/a071376b1216aabdd1695eec2175c374

What do you think of this idea?


================
Comment at: src/cxa_thread_atexit.cpp:42
@@ +41,3 @@
+  // - thread_local destructors on other threads run on the first iteration
+  //   through the pthread_key destructors.  std::notify_all_at_thread_exit()
+  //   and similar functions must be careful to wait until the second iteration
----------------
Can you clarify what you mean by "other threads"?

How is libc++ supposed to detect and handle this problem? 


https://reviews.llvm.org/D21803





More information about the cfe-commits mailing list