HI Chris, I haven't reviewed the code yet, but it does sound like from your description that a ref_ptr<> would fix the problem. The only thing to watch with ref_ptr<> usage is the issue of circular references being set up, but in this context it doesn't seem like an issue.
Robert. On Tue, May 5, 2009 at 3:28 PM, Chris Denham <[email protected]> wrote: > 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 > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

