On Thu, May 06, 2021 at 08:00:56AM -0600, Todd C. Miller wrote: > 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
I did a quick investigation on my Linux machine and there mpv seems to be using libEGL_mesa.so instead of iris_dri.so. In this case I am not seeing a call to pthread_key_create at the start of video playback (there are some other places where pthread_key_create is called from but they don't cause a problem). So, not sure what happens in Linux when iris_dri.so is used. However, the Linux implementation of pthread_key_create seems to also not increment the refcount when the destructor is set so I don't yet see how it's solved there, assuming iris_dri.so behaves identically. Regards, Anindya