We have a plugin that consists of several shared libraries in our application that we need to update while the application is running. For performance reasons, we download and start using the new plugin before unloading the old plugin, and only when all threads are completed using the old plugin do we unload it. Since the libraries of the new plugin and the old plugin have the same characters, we dlopen() with RTLD_LOCAL . If we do not, the new plugin will randomly call characters from the old plugin from internal functions.
One plugin library does dynamic_cast() on an object that was created by another plugin library. This works on HP-UX, AIX, Solaris, and Windows, but not Linux. As far as I understand, this is because all of these OSs (compilers) use the class name for type comparisons (in dynamic_cast() ), but Linux uses name string addresses for this comparison (to improve performance), and since each library has its own object type_info (since it was loaded using RTLD_LOCAL ), the addresses are different, and so the same types do not seem to match dynamic_cast() .
Is there a way to do one of the following:
- Make
type_info only type_info objects, as if RTLD_GLOBAL was specified RTLD_GLOBAL . type_info compiler use class name comparisons instead of type_info addresses to compare between types.
? The compiler we use is:
$ icpc -V Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.0.0.084 Build 20101006 Copyright (C) 1985-2010 Intel Corporation. All rights reserved.
source share