On Thu, 06 May 2021 09:32:28 +0200, Sebastien Marie wrote: > We already take care of such situation with __cxa_thread_atexit_impl > (in libc/stdlib/thread_atexit.c), by keeping an additionnal reference > on object loaded (it makes ld.so aware that it is still used and so > dlclose() doesn't unload it). > > I used the same idiom for pthread_key_create() and used dlctl(3) in > the same way with the destructor address.
This will set STAT_NODELETE so the DSO will never really get unloaded. That's not a problem for atexit() since the process is headed for the exit. I'm less sure about using it here since we don't have a way to unreference the DSO upon pthread_key_delete(). - todd