I found below notes in code. It say RTLD_GLOBAL will cause static global variable initialization problem when reopen the library.
I try load and unload the library, and the static variable is int correct. I don't know under what circumstances the problem will occur ? In fact, I found that some static variables in template classes and inline functions will cause this problem. I did not find these situations in the code.
|
// Insert into graveyard |
|
// We remove the metaobject from its factory map, but we don't destroy it...instead it |
|
// saved to a "graveyard" to the side. |
|
// This is due to our static global variable initialization problem that causes factories |
|
// to not be registered when a library is closed and then reopened. |
|
// This is because it's truly not closed due to the use of global symbol binding i.e. |
|
// calling dlopen with RTLD_GLOBAL instead of RTLD_LOCAL. |
|
// We require using the former as the which is required to support RTTI |
|
insertMetaObjectIntoGraveyard(meta_obj); |
|
} else { |
I found the RTLD_NODELETE dlopen doc, dlopen not use the RTLD_NODELETE option, I also make some test that static variable inited correctly.
RTLD_NODELETE (since glibc 2.2)
Do not unload the library during dlclose(). Consequently, the library's static variables are not reinitialized if the library is reloaded with dlopen() at a later time. This flag is not specified in POSIX.1-2001.
I found below notes in code. It say
RTLD_GLOBALwill cause static global variable initialization problem when reopen the library.I try load and unload the library, and the static variable is int correct. I don't know under what circumstances the problem will occur ? In fact, I found that some static variables in template classes and inline functions will cause this problem. I did not find these situations in the code.
class_loader/src/class_loader_core.cpp
Lines 235 to 244 in 8864be3
I found the
RTLD_NODELETEdlopen doc, dlopen not use the RTLD_NODELETE option, I also make some test that static variable inited correctly.