[osg-users] Alter tree in safe mode.

Robert Osfield robert.osfield at gmail.com
Thu Dec 17 09:11:03 PST 2015


Hi Dario,

The stack trace suggests a problem with the parent list.  The code you've
supplied itself in principle looks OK, although generally when doing this
type of work I don't use callbacks, instead placing the sync in a separate
call in in the viewer's frame - i.e. how the DatabasePager works.  One can
use an viewer UpdateOperation for this type of scene graph sync work.

W.r.t the parent list adjustment causing a race condition.  At least in
last few releases of the OSG there has been a mutex to protect access
add/remove from the parent list.  Which version of the OSG are you using?
Check to see whether it's got the appropriate mutex code in the
Node::addParent()/removeParent().

Robert.

On 17 December 2015 at 16:56, Dario Minieri <paradox at cheapnet.it> wrote:

> Hi,
>
> I have a system which use an UpdateCallback for every node which can be
> modified (adding or removing his children).  Sometime I have segmentation
> fault inside the callback, like this one:
>
> #0  0x00007ffff4b02cc9 in __GI_raise (sig=sig at entry=6) at
> ../nptl/sysdeps/unix/sysv/linux/raise.c:56
> #1  0x00007ffff4b060d8 in __GI_abort () at abort.c:89
> #2  0x00007ffff5107535 in __gnu_cxx::__verbose_terminate_handler() () from
> /usr/lib/x86_64-linux-gnu/libstdc++.so.6
> #3  0x00007ffff51056d6 in ?? () from
> /usr/lib/x86_64-linux-gnu/libstdc++.so.6
> #4  0x00007ffff5105703 in std::terminate() () from
> /usr/lib/x86_64-linux-gnu/libstdc++.so.6
> #5  0x00007ffff5105922 in __cxa_throw () from
> /usr/lib/x86_64-linux-gnu/libstdc++.so.6
> #6  0x00007ffff5105e0d in operator new(unsigned long) () from
> /usr/lib/x86_64-linux-gnu/libstdc++.so.6
> #7  0x00007ffff0e83ac6 in std::vector<osg::Group*,
> std::allocator<osg::Group*>
> >::_M_insert_aux(__gnu_cxx::__normal_iterator<osg::Group**,
> std::vector<osg::Group*, std::allocator<osg::Group*> > >, osg::Group*
> const&) () from /usr/local/lib/libosg.so.100
> #8  0x00007ffff0e83266 in osg::Node::addParent(osg::Group*) () from
> /usr/local/lib/libosg.so.100
> #9  0x00007ffff0e14bad in osg::Group::insertChild(unsigned int,
> osg::Node*) () from /usr/local/lib/libosg.so.100
> #10 0x00007ffff488501f in AlterTreeNodeCallback::operator()(osg::Node*,
> osg::NodeVisitor*) () from /usr/local/lib/libSimWorld.so
> #11 0x00007ffff0e150b2 in osg::Group::accept(osg::NodeVisitor&) () from
> /usr/local/lib/libosg.so.100
> #12 0x00007ffff0e13af3 in osg::Group::traverse(osg::NodeVisitor&) () from
> /usr/local/lib/libosg.so.100
> #13 0x00007ffff0e150b2 in osg::Group::accept(osg::NodeVisitor&) () from
> /usr/local/lib/libosg.so.100
> #14 0x00007ffff0e13af3 in osg::Group::traverse(osg::NodeVisitor&) () from
> /usr/local/lib/libosg.so.100
> #15 0x00007ffff0e150b2 in osg::Group::accept(osg::NodeVisitor&) () from
> /usr/local/lib/libosg.so.100
> #16 0x00007fffeff514a1 in osgViewer::Viewer::updateTraversal() () from
> /usr/local/lib/libosgViewer.so.100
> #17 0x00007fffeff5b685 in osgViewer::ViewerBase::frame(double) () from
> /usr/local/lib/libosgViewer.so.100
> #18 0x00007ffff04356e4 in QGLWidget::glDraw() () from
> /usr/lib/x86_64-linux-gnu/libQt5OpenGL.so.5
> #19 0x00007ffff04326f9 in QGLWidget::paintEvent(QPaintEvent*) () from
> /usr/lib/x86_64-linux-gnu/libQt5OpenGL.so.5
> #20 0x00007ffff5521302 in QWidget::event(QEvent*) () from
> /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
> #21 0x00007ffff54e5c8c in QApplicationPrivate::notify_helper(QObject*,
> QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
> #22 0x00007ffff54eae56 in QApplication::notify(QObject*, QEvent*) () from
> /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
> #23 0x00007ffff6488c2d in QCoreApplication::notifyInternal(QObject*,
> QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
> #24 0x00007ffff551bbea in QWidgetPrivate::drawWidget(QPaintDevice*,
> QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
>    from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
>
> Adding (insertChild) some new node at runtime, show the problem. This
> happens especially when I made some remove and insert in short time.
>
> The callback is something like this:
>
>
> Code:
> void AlterCallback::operator()(Node* p_node, NodeVisitor* p_nv) {
>   if (p_node != NULL) {
>     Group* p_group = p_node->asGroup();
>     if (p_group != NULL) {
>       while (m_add_nodes.size() > 0) {
>           Node* l_node = (Node*)m_add_nodes.popFront();
>           p_group->addChild(l_node);
>         }
>
>       while (m_remove_nodes.size() > 0) {
>         Node* l_node = (Node*)m_remove_nodes.popFront();
>         p_group->removeChild(l_node);
>       }
>     }
>
>     traverse(p_node, p_nv);
>   }
> }
>
>
>
> m_add_nodes and m_remove_nodes are thread-safe structures which holds the
> list of nodes (pointers) to add and remove.
>
> This is a good way to alter the tree at runtime?
>
> Thank you!
>
> Cheers,
> Dario
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65891#65891
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20151217/27c1643d/attachment-0003.htm>


More information about the osg-users mailing list