Re: Re: std::function and shared object libraries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 On Tue, 2015-06-16 at 09:43 +0100, Jonathan Wakely wrote:
> So in the case of the OP, that would amount to allocated objects
> (ex. function template) 

I'm pretty sure that is NOT the case.  The relevant chunk of memory was created at compile time within a module that was part of the .so file.  It is code that was loaded and unloaded as part of that .so file.  
  
The run-time allocated object is not lost by unloading the .so file.  

> isn't the function template still around in memory (assuming it was
> allocated by the app's mem mgr)?

That is the wrong assumption.  The template is instantiated at compile time within the compilation of a module in the .so, not at run time.

An object of a templated type might be allocated at run time in the single heap shared by both the main module and the .so.  But the type itself is instantiated at compile time and ends up being in one place or the other (main image or .so) depending on exactly how things are coded.

> And so the problem is that the shared object's *code* is gone
> and so the std::function dtor segfaults because it's trying to execute
> code that's no longer in the address space?

Not exactly.  That dtor itself (not just things it might call) is code in the shared object.







[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux