Coder Social home page Coder Social logo

Comments (2)

hidmic avatar hidmic commented on August 19, 2024

What are you proposing @daohu527 ? IIUC RTLD_GLOBAL is used to ensure RTTI (and dynamic_cast) works, but it also means it won't get unloaded if a symbol within the executable space depends on a symbol in that loaded shared library. That why it goes to a "graveyard".

from class_loader.

daohu527 avatar daohu527 commented on August 19, 2024

I mean that even if dlopen sets RTLD_GLOBAL, it will be dynamically unloaded, including static variables.

We are divided into 2 situations to discuss

1 case

Some static variable with STB_GNU_UNIQUE will still in memory when call dlclose. you can ref to Destructor of a global static variable in a shared library is not called on dlclose.

There is not this case in below register code. (static variables in template classes and inline functions)

struct ProxyExec ## UniqueID \
{ \
typedef Derived _derived; \
typedef Base _base; \
ProxyExec ## UniqueID() \
{ \
if (!std::string(Message).empty()) { \
CONSOLE_BRIDGE_logInform("%s", Message);} \
class_loader::impl::registerPlugin<_derived, _base>(#Derived, #Base); \
} \
}; \
static ProxyExec ## UniqueID g_register_plugin_ ## UniqueID; \

2 case

Instructions in the man manual dlopen

not this case too.

RTLD_NODELETE (since glibc 2.2)
Do not unload the shared object during dlclose(). Consequently, the object's static and global variables are not reinitialized if the object is reloaded with dlopen() at a later time.

The following two descriptions may appear, unless the ros module can be referenced by ros module. we will explain in next subsection.

The dynamic linker maintains reference counts for object handles, so a dynamically loaded shared object is not deallocated until dlclose() has been called on it as many times as dlopen() has succeeded on it.

Symbols in this object might be required in another object because this object was opened with the RTLD_GLOBAL flag and one of its symbols satisfied a relocation in another object.

example

If A is an ros module and C is references A.

A       // A is a ros module
C <- A  // C references A

We first load A and then load C, the A module will Implicit load only once (reference counts is 2) and register once, then if we unload the library A, the A will still in memory, because the dlopen reference counts is 1, after that we load A again, and A will not register because A is already in memory.

reason

So the core principle is, can ROS modules be referenced by other ROS modules? But it is unreasonable to say that RTLD_GLOBAL causes this problem.

from class_loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.