Hi All,

I've had a problem similar to this for awhile in that a dynamically
loadable plugin of my own, which itself links to libosg.so, crashes as
soon as I do a dlopen on it on Linux. Curiously enough it does not
happen on windows, and only happens on Linux when I don't link the
main executable with the osg libraries. Of course this defeats the
purpose of the plugins. I haven''t been able to trace it yet. This
exact same thing happens also on windows but with the ACE (networking)
libraries linked by a plugin, but I figured it had to do with the
socket initialization under windows. I can't imagine any explanation
for the OSG-Linux case.

Chris

On 12/7/06, Robert Osfield <[EMAIL PROTECTED]> wrote:
Hi Philip,

On 12/7/06, Philip Lowman <[EMAIL PROTECTED]> wrote:
> Robert,
>
> You're absolutely correct.  Simply calling
>     osgDB::Registry::instance()->closeAllLibraries();
> within the plugin using OSG fixes the dlclose() problem.
>
> Does dlclose() not call the destructors of singletons like
> osgDB::Registry?  It doesn't look like it does, at least not within OSG.

Its order of destruction that is critical - the OSG plugins unregister
themselves with osgDB::Registry to keep everything consistent, if
osgDB is unloaded before the plugins then you'll end up with a crash.

> Since adding this in our plugin seemed less than optimal, I tested some
> code to use the __attribute__((destructor)) method documented in the
> dlclose manpage to call closeAllLibraries() and the other methods within
> osgDB::~Registry() as an extern'd function in Registry.cpp.  I got the
> special function to execute on dlclose() but unfortunately my code was
> still segfaulting (although with a completely different backtrace).

You can do :

 osgDB::Registry::instance(0) to destroy the Registry singleton.


Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to