[osg-users] Deleting still referenced object

Richard Harrison rjh at zaretto.com
Thu Jan 17 02:25:29 PST 2019


Hi Lawrence;

Thanks for the help.

Sorry for the confusion; it doesn't actually fail on that line; it fails 
deep inside CopyOp; this is the stack trace from the previous code;

osg130-osg.dll!osg::CopyOp::operator()(const osg::Node * node) Line 
56    C++
      osg130-osg.dll!osg::Group::Group(const osg::Group & group, const 
osg::CopyOp & copyop) Line 40    C++
      osg130-osg.dll!osg::Group::clone(const osg::CopyOp & copyop) Line 
38    C++
      osg130-osg.dll!osg::clone<osg::Node>(const osg::Node * t, const 
osg::CopyOp & copyop) Line 250    C++
      osg130-osg.dll!osg::Group::Group(const osg::Group & group, const 
osg::CopyOp & copyop) Line 40    C++
      osg130-osg.dll!osg::Group::clone(const osg::CopyOp & copyop) Line 
38    C++
      osg130-osg.dll!osg::clone<osg::Node>(const osg::Node * t, const 
osg::CopyOp & copyop) Line 250    C++
      fgfs.exe!simgear::copyModel(osg::Node * model) Line 94    C++
      fgfs.exe!sgLoad3DModel_internal(const SGPath & path, const 
osgDB::Options * dbOptions, SGPropertyNode * overlay) Line 342    C++

copy model (simgear model.cxx:84) uses the following flags.

Node* copyModel(Node* model)
{
     const CopyOp::CopyFlags flags = (CopyOp::DEEP_COPY_ALL
                                      & ~CopyOp::DEEP_COPY_TEXTURES
                                      & ~CopyOp::DEEP_COPY_IMAGES
                                      & ~CopyOp::DEEP_COPY_STATESETS
                                      & ~CopyOp::DEEP_COPY_STATEATTRIBUTES
                                      & ~CopyOp::DEEP_COPY_ARRAYS
                                      & ~CopyOp::DEEP_COPY_PRIMITIVES
                                      // This will preserve display 
lists ...
                                      & ~CopyOp::DEEP_COPY_DRAWABLES
                                      & ~CopyOp::DEEP_COPY_SHAPES);
     return (CopyOp(flags))(model);
}

At the top of the stack inside operator() the node in question is all 
garbage - which looks like something that has been deleted.

         osg::Object    {_name={...} _dataVariance=??? 
_userDataContainer=??? }    osg::Object
         _initialBound    {_center={_v=0x8003d900ed55904f {???, ???, 
???} } _radius=??? } osg::BoundingSphereImpl<osg::Vec3f>
         _computeBoundCallback    {_ptr=??? } 
osg::ref_ptr<osg::Node::ComputeBoundingSphereCallback>
         _boundingSphere    {_center={_v=0x8003d900ed559067 {???, ???, 
???} } _radius=??? } osg::BoundingSphereImpl<osg::Vec3f>
         _boundingSphereComputed    <Unable to read memory>
         _parents    { size=??? }    std::vector<osg::Group 
*,std::allocator<osg::Group *> >
         _updateCallback    {_ptr=??? } osg::ref_ptr<osg::Callback>
         _numChildrenRequiringUpdateTraversal    <Unable to read memory>
         _eventCallback    {_ptr=??? } osg::ref_ptr<osg::Callback>
         _numChildrenRequiringEventTraversal    <Unable to read memory>
         _cullCallback    {_ptr=??? } osg::ref_ptr<osg::Callback>
         _cullingActive    <Unable to read memory>
         _numChildrenWithCullingDisabled    <Unable to read memory>
         _numChildrenWithOccluderNodes    <Unable to read memory>
         _nodeMask    <Unable to read memory>
         _stateset    {_ptr=??? } osg::ref_ptr<osg::StateSet>

On 17/01/2019 10:56, Voerman, L. wrote:

> Hi Richard,
> I can't see how you can get a segfault on the line you indicate, so I 
> guess the node is somehow corrupted and the segfault is somewhere in 
> the copyOp.
> I can only guess at what might be going wrong there, but my first 
> guess would be the DEEP_COPY_USERDATA.
> Laurens.
>
> On Thu, Jan 17, 2019 at 8:13 AM Richard Harrison <rjh at zaretto.com 
> <mailto:rjh at zaretto.com>> wrote:
>
>     On 15/01/2019 09:03, Robert Osfield wrote:
>
>     >> illustrated it well) and I'm currently flying one of my long
>     test routes.
>     > Fingers and toes crossed.
>
>     ..and alas after 30h I've got a similar looking problem; the
>     pattern is
>     the same i.e. DatabasePager loading something whilst ObjectCache is
>     expiring.
>
>     This time it's a segfault in the DatabasePager during a copy of a
>     model
>     that has just been loaded (simgear, SGReaderWriterXML.cxx:342)
>
>     options->setDatabasePath(texturepath.local8BitStr());
>              osgDB::ReaderWriter::ReadResult modelResult;
>              modelResult =
>     osgDB::readRefNodeFile(modelpath.local8BitStr(),
>     options.get());
>              if (!modelResult.validNode())
>                  throw sg_io_exception("Failed to load 3D model:" +
>     modelResult.message(),
>                                        modelpath);
>      >       model = copyModel(modelResult.getNode());
>
>     The object currently being expired in the ObjectCache doesn't seem to
>     bear any relation to the model being loaded; one is a windsock and
>     the
>     other a radio tower.
>
>     This is after I changed all of the osg::getSomething into
>     osg::getRefSomething.
>
>     I'm now a little confused as I was sure that the fix would work; I've
>     kept the debug session open in case there is anything that I need to
>     inspect.
>
>
>     _______________________________________________
>     osg-users mailing list
>     osg-users at lists.openscenegraph.org
>     <mailto:osg-users at lists.openscenegraph.org>
>     http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




More information about the osg-users mailing list