I have traced this back to a bug in /usr/include/libcec/cecloader.h.
This file has a global variable g_libCEC which is used to store the return value of the dlopen call for libcec.so.
This handle is used in LibCecInitialise to lookup the value of symbol CECInitialise.
The file cecloader.h contains both a Windows and a Linux version of LibCecInitialise and UnloadLibCec.
The Windows version of UnloadLibCec sets g_libCEC to NULL but the Linux version does NOT.
On Linux, the second time LibCecInitialise is called the now invalid g_libCEC handle is used for the symbol lookup and this is what causes dlsym to crash.
The solution is to set g_libCEC to NULL after dlclose like it is done in the Windows version of the code.
For reference, this is the WIndows version as found in /usr/include/libcec/cecloader.h of Fedora 33:
The MythTV application segfaults in dlsym called by LibCecInitialize in the following calling sequence:
I have traced this back to a bug in /usr/include/libcec/cecloader.h. This file has a global variable g_libCEC which is used to store the return value of the dlopen call for libcec.so. This handle is used in LibCecInitialise to lookup the value of symbol CECInitialise. The file cecloader.h contains both a Windows and a Linux version of LibCecInitialise and UnloadLibCec. The Windows version of UnloadLibCec sets g_libCEC to NULL but the Linux version does NOT. On Linux, the second time LibCecInitialise is called the now invalid g_libCEC handle is used for the symbol lookup and this is what causes dlsym to crash.
The solution is to set g_libCEC to NULL after dlclose like it is done in the Windows version of the code.
For reference, this is the WIndows version as found in /usr/include/libcec/cecloader.h of Fedora 33:
This is the Linux code from the same file: