On Fri, 2020-10-23 at 16:15 -0500, Benjamin Marzinski wrote: > The multipathd tur checker thread is designed to be able to finish at > any time, even after the tur checker itself has been freed. The > multipathd shutdown code makes sure all the checkers have been freed > before freeing the checker_class and calling dlclose() to unload the > DSO, but this doesn't guarantee that the checker threads have > finished. > If one hasn't, the DSO will get unloaded while the thread still > running > code from it, causing a segfault. Unfortunately, it's not possible to > be > sure that all tur checker threads have ended during shutdown, without > making them joinable. > > However, since libmultipath will never be reinitialized after it has > been uninitialzed, not dlclosing the tur checker DSO once a thread is > started has minimal cost (keeping the DSO code around until the > program > exits, which usually happens right after freeing the checkers).
I'm not against this, but have you considered using an atomic refcount for the DSO? With every tur thread starting, we could increase it, and decrease it in the cleanup function of the thread when it exits. That should be safe. If the refcount was positive when we exit, we could refrain from unloading the DSO. Regards, Martin -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel