HDF5 2.0.0.2ad0391
API Reference
|
Any application that creates threads that use the HDF5 library must join those threads before either process exit or library close through H5close(). If all HDF5-using threads aren't joined, the threads may exhibit undefined behavior.
It would in principle be possible to make it safe to have threads continue using HDF5 resources after a call to H5close by keeping a count of threads within the library. (There is probably no solution to an early process exit producing undefined behavior within threads.) This method would only be able to count (and presumably, only need to count) threads that directly interact with the library. Because each thread would need to be counted exactly once, this would most likely be done by use of a thread-local key with e.g. a boolean value used to track whether the a global atomic thread counter has already counted this thread. Then, if H5close is invoked while this thread counter is above one (because one thread must be doing the closing), the library would not close, and instead keep its resources valid to hopefully avoid bad behavior with the threads.
The issues with this approach are as follows:
Despite these issues, if a more performant method was found to perform threadcounting like this, it might still constitute a worthwhile change.