Hi Stephan,
My guess is that the problem is probably related to the plugins
unregistering themselves after the static s_registry variable has been
reset to 0.
As an experiment I've introuced a destruct() protected method that
implements the destructor(), with the Registry::instance(true) calling
this first before setting the static ref_ptr<> to 0.
Could you try this?
Robert.
On 6/7/07, Stephan Maximilian Huber <[EMAIL PROTECTED]> wrote:
Hi Robert,
I notice a crash when tearing down osgDB::Registry when a plugin is used
(I notices the bug in osg.1.2 the first time). In normal usage-pattern
you won't notice the crash, because the app is terminated already.
Forcing the destructor of osgDB::Registry shows the bug, here's a simple
demo-app:
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel)
{
std::cout << argv[0] <<": No data loaded." << std::endl;
}
loadedModel = NULL;
osgDB::Registry::instance(true);
return 0;
}
Here's the crash-log when loading cow.osg (the crash is not related to
the osg-plugin, it happens also with other plugins)
#0 0x002291ad in osg::Referenced::unref at Referenced:152
#1 0x0023e1d4 in osg::ref_ptr<osgDB::ReaderWriter>::~ref_ptr at
ref_ptr:30
#2 0x0023f5fd in
__gnu_cxx::new_allocator<osg::ref_ptr<osgDB::ReaderWriter> >::destroy at
new_allocator.h:107
#3 0x0023f620 in std::_Destroy<osg::ref_ptr<osgDB::ReaderWriter>*,
std::allocator<osg::ref_ptr<osgDB::ReaderWriter> > > at stl_construct.h:174
#4 0x0024218c in std::vector<osg::ref_ptr<osgDB::ReaderWriter>,
std::allocator<osg::ref_ptr<osgDB::ReaderWriter> > >::~vector at
stl_vector.h:273
#5 0x00216eb1 in osgDB::Registry::~Registry at Registry.cpp:264
#6 0x002291b7 in osg::Referenced::unref at Referenced:152
#7 0x0023dfbb in osg::ref_ptr<osgDB::Registry>::operator= at ref_ptr:54
#8 0x0021bb88 in osgDB::Registry::instance at Registry.cpp:125
#9 0x00003a37 in main at test.cpp:240
If I change the order of destruction of the various maps and vectors the
app does not crash anymore. Here's my new destructor:
Registry::~Registry()
{
// switch off the pager and its associated thread before we clean up
// rest of the Registry.
_databasePager = 0;
// clean up the SharedStateManager
_sharedStateManager = 0;
// object cache clear needed here to prevent crash in unref() of
// the objects it contains when running the TXP plugin.
// Not sure why, but perhaps there is is something in a TXP plugin
// which is deleted the data before its ref count hits zero, perhaps
// even some issue with objects be allocated by a plugin that is
// mainted after that plugin is deleted... Robert Osfield, Jan 2004.
clearObjectCache();
clearArchiveCache();
_objectWrapperMap.clear();
_imageWrapperMap.clear();
_drawableWrapperMap.clear();
_stateAttrWrapperMap.clear();
_uniformWrapperMap.clear();
_nodeWrapperMap.clear();
_classNameWrapperMap.clear();
_rwList.clear();
closeAllLibraries();
}
I don't know what the reason is for the crash I am getting, I think when
closing a lib on Mac OS X, all accoubied memory get freed, so the
osgDB::Registry still have some dangling references to objects created
inside the lib. But I am no expert, just my thoughts.
If this change is reasonable to you, I can resubmit the whole file to
osg-submissions.
cheers,
Stephan
_______________________________________________
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/