I've just tracked down a problem with my osg application crashing and was
wondering about the correct place to put the fix.
I can fix it outside osg but it occured to me that it might be better to fix
it within osg because I think its a bug that has the potential for causing
memory corruption.
The problematic code (pasted & annotated below) is in
osgManipulator::CommandManager::disconnect() which removes a dragger object
from two STL maps.
The problem occurs when _draggerSelectionMap contains the last reference to
the passed dragger object. In this scenario, _draggerConstraintMap.erase is
called with a pointer to a deleted object, which actually results in a call
to ref for the deleted dragger object; this is very bad!
The fix I suggest is to change CommandManager::disconnect to take
'ref_ptr<Dragger>' parameter rather than a 'C++ reference'.
Happy to post to submissions list if this seems sensible.
bool CommandManager::disconnect(Dragger& dragger)
{
_draggerSelectionMap.erase(&dragger);
_draggerConstraintMap.erase(&dragger); // dragger may be deleted at
this point!!!!
return true;
}
Cheers.
Chris.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org