<div dir="ltr"><div><div><div>Hi Dario,<br><br></div>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.<br><br></div>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().<br><br></div>Robert.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 17 December 2015 at 16:56, Dario Minieri <span dir="ltr"><<a href="mailto:paradox@cheapnet.it" target="_blank">paradox@cheapnet.it</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
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:<br>
<br>
#0 0x00007ffff4b02cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56<br>
#1 0x00007ffff4b060d8 in __GI_abort () at abort.c:89<br>
#2 0x00007ffff5107535 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6<br>
#3 0x00007ffff51056d6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6<br>
#4 0x00007ffff5105703 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6<br>
#5 0x00007ffff5105922 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6<br>
#6 0x00007ffff5105e0d in operator new(unsigned long) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6<br>
#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<br>
#8 0x00007ffff0e83266 in osg::Node::addParent(osg::Group*) () from /usr/local/lib/libosg.so.100<br>
#9 0x00007ffff0e14bad in osg::Group::insertChild(unsigned int, osg::Node*) () from /usr/local/lib/libosg.so.100<br>
#10 0x00007ffff488501f in AlterTreeNodeCallback::operator()(osg::Node*, osg::NodeVisitor*) () from /usr/local/lib/libSimWorld.so<br>
#11 0x00007ffff0e150b2 in osg::Group::accept(osg::NodeVisitor&) () from /usr/local/lib/libosg.so.100<br>
#12 0x00007ffff0e13af3 in osg::Group::traverse(osg::NodeVisitor&) () from /usr/local/lib/libosg.so.100<br>
#13 0x00007ffff0e150b2 in osg::Group::accept(osg::NodeVisitor&) () from /usr/local/lib/libosg.so.100<br>
#14 0x00007ffff0e13af3 in osg::Group::traverse(osg::NodeVisitor&) () from /usr/local/lib/libosg.so.100<br>
#15 0x00007ffff0e150b2 in osg::Group::accept(osg::NodeVisitor&) () from /usr/local/lib/libosg.so.100<br>
#16 0x00007fffeff514a1 in osgViewer::Viewer::updateTraversal() () from /usr/local/lib/libosgViewer.so.100<br>
#17 0x00007fffeff5b685 in osgViewer::ViewerBase::frame(double) () from /usr/local/lib/libosgViewer.so.100<br>
#18 0x00007ffff04356e4 in QGLWidget::glDraw() () from /usr/lib/x86_64-linux-gnu/libQt5OpenGL.so.5<br>
#19 0x00007ffff04326f9 in QGLWidget::paintEvent(QPaintEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5OpenGL.so.5<br>
#20 0x00007ffff5521302 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5<br>
#21 0x00007ffff54e5c8c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5<br>
#22 0x00007ffff54eae56 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5<br>
#23 0x00007ffff6488c2d in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5<br>
#24 0x00007ffff551bbea in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()<br>
from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5<br>
<br>
Adding (insertChild) some new node at runtime, show the problem. This happens especially when I made some remove and insert in short time.<br>
<br>
The callback is something like this:<br>
<br>
<br>
Code:<br>
void AlterCallback::operator()(Node* p_node, NodeVisitor* p_nv) {<br>
if (p_node != NULL) {<br>
Group* p_group = p_node->asGroup();<br>
if (p_group != NULL) {<br>
while (m_add_nodes.size() > 0) {<br>
Node* l_node = (Node*)m_add_nodes.popFront();<br>
p_group->addChild(l_node);<br>
}<br>
<br>
while (m_remove_nodes.size() > 0) {<br>
Node* l_node = (Node*)m_remove_nodes.popFront();<br>
p_group->removeChild(l_node);<br>
}<br>
}<br>
<br>
traverse(p_node, p_nv);<br>
}<br>
}<br>
<br>
<br>
<br>
m_add_nodes and m_remove_nodes are thread-safe structures which holds the list of nodes (pointers) to add and remove.<br>
<br>
This is a good way to alter the tree at runtime?<br>
<br>
Thank you!<br>
<br>
Cheers,<br>
Dario<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=65891#65891" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=65891#65891</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div><br></div>