I have a problem where my application crashes when one of the threads
exits. This happens because this thread has called some HDF5 functions
and the library has registered a pthread key using pthread_key_create
(I've built the library in thread safe mode). The code which executes the
HDF5 calls is inside a shared object loaded with dlopen. The HDF5
library is statically linked to this shared object, so the code of HDF5 is
part of the code for the shared object. The thread that crashes unloads
the shared object just before it finishes. The crash happens somewhere
in the pthread's code, because the pthread library tries to execute the
destructor for key, but the code is unloaded and it no longer exists.
I've seen that there is code that handles similar issues with atexit, but
there is nothing related to thread exit.
My current solution is to disable the destructor for the keys and to
accept that there will be some leaks.
Is there something else that it is more appropriate and not as hacky
which I can do?
Do you think that the leaks might be serious if my application doesn't
spawn/destroy new threads very often?
I've tried both 1.8.7 and 1.8.13. They behave the same.