How to fix Ogre3d segfault with std::_Rb_tree_insert_and_rebalance?

Balázs Béla
  • How to fix Ogre3d segfault with std::_Rb_tree_insert_and_rebalance? Balázs Béla

    I'm working on a 3d music visualizer using Ogre3d, basically it's a spectrum analizer, a lot like the old xmms plugin: http://www.youtube.com/watch?v=_6NKBiwYN24

    It works well, the bars are drawn and updated, there are no framerate issues, but it crashes randomly. Sometimes it can run without problems, finish the song, other times it crashes instantly, other times the music just stops, without a crash.

    Here is the source code for the main class :

    https://github.com/balazsbela/OgreVisualizer/blob/master/src/VisualizerApplication.cpp#L221

    Also the crashes seem to happen less often when I display the framerate overlay from Ogre samples. Would limiting the framerate help ?

    The crashes are seemingly random. Is it a performance issue ?

    Please help me out, I'm quite lost on this one, I also posted on Ogre3d forums but I received no responses.

    http://www.ogre3d.org/forums/viewtopic.php?f=2&t=63207

    I also tried stackoverflow: https://stackoverflow.com/questions/5050147/how-to-fix-ogre3d-segfault-with-std-rb-tree-insert-and-rebalance

    Backtrace:

    [email protected]:~/workspace/OgreVisualizer/Release$ gdb OgreVisualizer core
    GNU gdb (GDB) 7.2-debian
    Copyright (C) 2010 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "i486-linux-gnu".
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>...
    Reading symbols from /home/balazsbela/workspace/OgreVisualizer/Release/OgreVisualizer...done.
    [New Thread 17705]
    [New Thread 17702]
    [New Thread 17703]
    [New Thread 17700]
    Reading symbols from /usr/lib/libv4l/v4l1compat.so...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libv4l/v4l1compat.so
    Reading symbols from /usr/local/lib/libOgreMain.so.1.7.1...done.
    Loaded symbols for /usr/local/lib/libOgreMain.so.1.7.1
    Reading symbols from /usr/lib/libfftw3.so.3...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libfftw3.so.3
    Reading symbols from /usr/lib/libSDL_sound-1.0.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libSDL_sound-1.0.so.1
    Reading symbols from /usr/lib/libSDL-1.2.so.0...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libSDL-1.2.so.0
    Reading symbols from /usr/lib/libSDL_mixer-1.2.so.0...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libSDL_mixer-1.2.so.0
    Reading symbols from /usr/lib/libOIS-1.2.0.so...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libOIS-1.2.0.so
    Reading symbols from /usr/lib/libstdc++.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libstdc++.so.6
    Reading symbols from /lib/i686/cmov/libm.so.6...Reading symbols from /usr/lib/debug/lib/i686/cmov/libm-2.11.2.so...done.
    done.
    Loaded symbols for /lib/i686/cmov/libm.so.6
    Reading symbols from /lib/libgcc_s.so.1...(no debugging symbols found)...done.
    Loaded symbols for /lib/libgcc_s.so.1
    Reading symbols from /lib/i686/cmov/libc.so.6...Reading symbols from /usr/lib/debug/lib/i686/cmov/libc-2.11.2.so...done.
    done.
    Loaded symbols for /lib/i686/cmov/libc.so.6
    Reading symbols from /lib/i686/cmov/libpthread.so.0...Reading symbols from /usr/lib/debug/lib/i686/cmov/libpthread-2.11.2.so...done.
    done.
    Loaded symbols for /lib/i686/cmov/libpthread.so.0
    Reading symbols from /usr/local/lib/libv4l1.so.0...done.
    Loaded symbols for /usr/local/lib/libv4l1.so.0
    Reading symbols from /usr/lib/libfreetype.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libfreetype.so.6
    Reading symbols from /usr/lib/libSM.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libSM.so.6
    Reading symbols from /usr/lib/libICE.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libICE.so.6
    Reading symbols from /usr/lib/libX11.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libX11.so.6
    Reading symbols from /usr/lib/libXext.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libXext.so.6
    Reading symbols from /usr/lib/libXt.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libXt.so.6
    Reading symbols from /usr/lib/libXaw.so.7...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libXaw.so.7
    Reading symbols from /lib/i686/cmov/libdl.so.2...Reading symbols from /usr/lib/debug/lib/i686/cmov/libdl-2.11.2.so...done.
    done.
    Loaded symbols for /lib/i686/cmov/libdl.so.2
    Reading symbols from /usr/lib/libboost_thread.so.1.42.0...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libboost_thread.so.1.42.0
    Reading symbols from /usr/lib/libboost_date_time.so.1.42.0...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libboost_date_time.so.1.42.0
    Reading symbols from /usr/lib/libfreeimage.so.3...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libfreeimage.so.3
    Reading symbols from /usr/lib/libzzip-0.so.13...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libzzip-0.so.13
    Reading symbols from /usr/lib/libz.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libz.so.1
    Reading symbols from /usr/lib/libsmpeg-0.4.so.0...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libsmpeg-0.4.so.0
    Reading symbols from /usr/lib/libmikmod.so.2...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libmikmod.so.2
    Reading symbols from /usr/lib/libvorbis.so.0...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libvorbis.so.0
    Reading symbols from /usr/lib/libvorbisfile.so.3...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libvorbisfile.so.3
    Reading symbols from /usr/lib/libFLAC.so.8...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libFLAC.so.8
    Reading symbols from /usr/lib/libogg.so.0...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libogg.so.0
    Reading symbols from /usr/lib/sse2/libspeex.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/sse2/libspeex.so.1
    Reading symbols from /usr/lib/libasound.so.2...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libasound.so.2
    Reading symbols from /lib/i686/cmov/librt.so.1...Reading symbols from /usr/lib/debug/lib/i686/cmov/librt-2.11.2.so...done.
    done.
    Loaded symbols for /lib/i686/cmov/librt.so.1
    Reading symbols from /usr/lib/libdirectfb-1.2.so.9...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libdirectfb-1.2.so.9
    Reading symbols from /usr/lib/libfusion-1.2.so.9...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libfusion-1.2.so.9
    Reading symbols from /usr/lib/libdirect-1.2.so.9...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libdirect-1.2.so.9
    Reading symbols from /usr/lib/libvga.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libvga.so.1
    Reading symbols from /lib/ld-linux.so.2...Reading symbols from /usr/lib/debug/lib/ld-2.11.2.so...done.
    done.
    Loaded symbols for /lib/ld-linux.so.2
    Reading symbols from /usr/local/lib/libv4l2.so.0...done.
    Loaded symbols for /usr/local/lib/libv4l2.so.0
    Reading symbols from /lib/libuuid.so.1...(no debugging symbols found)...done.
    Loaded symbols for /lib/libuuid.so.1
    Reading symbols from /usr/lib/libxcb.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libxcb.so.1
    Reading symbols from /usr/lib/libXmu.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libXmu.so.6
    Reading symbols from /usr/lib/libXpm.so.4...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libXpm.so.4
    Reading symbols from /usr/lib/libjpeg.so.62...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libjpeg.so.62
    Reading symbols from /usr/lib/libmng.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libmng.so.1
    Reading symbols from /usr/lib/libopenjpeg.so.2...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libopenjpeg.so.2
    Reading symbols from /lib/libpng12.so.0...(no debugging symbols found)...done.
    Loaded symbols for /lib/libpng12.so.0
    Reading symbols from /usr/lib/libIlmImf.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libIlmImf.so.6
    Reading symbols from /usr/lib/libImath.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libImath.so.6
    Reading symbols from /usr/lib/libHalf.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libHalf.so.6
    Reading symbols from /usr/lib/libIex.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libIex.so.6
    Reading symbols from /usr/lib/libIlmThread.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libIlmThread.so.6
    Reading symbols from /lib/libx86.so.1...(no debugging symbols found)...done.
    Loaded symbols for /lib/libx86.so.1
    Reading symbols from /usr/local/lib/libv4lconvert.so.0...done.
    Loaded symbols for /usr/local/lib/libv4lconvert.so.0
    Reading symbols from /usr/lib/libXau.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libXau.so.6
    Reading symbols from /usr/lib/libXdmcp.so.6...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libXdmcp.so.6
    Reading symbols from /usr/lib/liblcms.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/liblcms.so.1
    Reading symbols from /usr/local/lib/OGRE/RenderSystem_GL.so...done.
    Loaded symbols for /usr/local/lib/OGRE/RenderSystem_GL.so
    Reading symbols from /usr/lib/libGLU.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libGLU.so.1
    Reading symbols from /usr/lib/libGL.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libGL.so.1
    Reading symbols from /usr/lib/libXrandr.so.2...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libXrandr.so.2
    Reading symbols from /usr/lib/libGLcore.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libGLcore.so.1
    Reading symbols from /usr/lib/tls/libnvidia-tls.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/tls/libnvidia-tls.so.1
    Reading symbols from /usr/lib/libXrender.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libXrender.so.1
    Reading symbols from /usr/lib/libXcursor.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libXcursor.so.1
    Reading symbols from /usr/lib/libXfixes.so.3...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/libXfixes.so.3
    Reading symbols from /lib/i686/cmov/libnss_compat.so.2...Reading symbols from /usr/lib/debug/lib/i686/cmov/libnss_compat-2.11.2.so...done.
    done.
    Loaded symbols for /lib/i686/cmov/libnss_compat.so.2
    Reading symbols from /lib/i686/cmov/libnsl.so.1...Reading symbols from /usr/lib/debug/lib/i686/cmov/libnsl-2.11.2.so...done.
    done.
    Loaded symbols for /lib/i686/cmov/libnsl.so.1
    Reading symbols from /lib/i686/cmov/libnss_nis.so.2...Reading symbols from /usr/lib/debug/lib/i686/cmov/libnss_nis-2.11.2.so...done.
    done.
    Loaded symbols for /lib/i686/cmov/libnss_nis.so.2
    Reading symbols from /lib/i686/cmov/libnss_files.so.2...Reading symbols from /usr/lib/debug/lib/i686/cmov/libnss_files-2.11.2.so...done.
    done.
    Loaded symbols for /lib/i686/cmov/libnss_files.so.2
    Reading symbols from /usr/lib/alsa-lib/libasound_module_rate_speexrate.so...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/alsa-lib/libasound_module_rate_speexrate.so
    Reading symbols from /usr/lib/sse2/libspeexdsp.so.1...(no debugging symbols found)...done.
    Loaded symbols for /usr/lib/sse2/libspeexdsp.so.1
    Core was generated by `./OgreVisualizer'.
    Program terminated with signal 11, Segmentation fault.
    #0  0xb6dc563d in std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&) ()
       from /usr/lib/libstdc++.so.6
    (gdb) bt
    #0  0xb6dc563d in std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&) ()
       from /usr/lib/libstdc++.so.6
    #1  0xb73bb3c2 in std::_Rb_tree<Ogre::Node*, Ogre::Node*, std::_Identity<Ogre::Node*>, std::less<Ogre::Node*>, Ogre::STLAllocator<Ogre::Node*, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >::_M_insert_(std::_Rb_tree_node_base const*, std::_Rb_tree_node_base const*, Ogre::Node* const&) ()
       from /usr/local/lib/libOgreMain.so.1.7.1
    #2  0xb73b5a52 in _M_insert_unique (this=0xb6157ea0, child=0xb616aff8, forceParentUpdate=false) at /usr/include/c++/4.4/bits/stl_tree.h:1182
    #3  insert (this=0xb6157ea0, child=0xb616aff8, forceParentUpdate=false) at /usr/include/c++/4.4/bits/stl_set.h:411
    #4  Ogre::Node::requestUpdate (this=0xb6157ea0, child=0xb616aff8, forceParentUpdate=false)
        at /home/balazsbela/Downloads/ogre_src_v1-7-1/OgreMain/src/OgreNode.cpp:805
    #5  0xb73b6a40 in Ogre::Node::needUpdate (this=0xb616aff8, forceParentUpdate=92)
        at /home/balazsbela/Downloads/ogre_src_v1-7-1/OgreMain/src/OgreNode.cpp:789
    #6  0xb73b5038 in Ogre::Node::setScale (this=0x1825c, scale=...) at /home/balazsbela/Downloads/ogre_src_v1-7-1/OgreMain/src/OgreNode.cpp:638
    #7  0x0805d306 in VisualizerApplication::adjustNodes (this=0x9cd4808) at ../src/VisualizerApplication.cpp:236
    #8  0xb6e867f0 in ?? () from /usr/lib/libSDL_mixer-1.2.so.0
    #9  0xb6e8719a in ?? () from /usr/lib/libSDL_mixer-1.2.so.0
    #10 0xb6ed9b0d in ?? () from /usr/lib/libSDL-1.2.so.0
    #11 0xb6ee185e in ?? () from /usr/lib/libSDL-1.2.so.0
    #12 0xb6f2e0bd in ?? () from /usr/lib/libSDL-1.2.so.0
    #13 0xb6bc7955 in start_thread (arg=0xb198ab70) at pthread_create.c:300
    #14 0xb6ca6e7e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
    (gdb) 
    

    Ogre.log: http://pastie.org/1581790

  • Standard C++ containers do not offer guarantees of threadsafety, and I don't think OgreNodes do either. You're probably adjusting the node at the same time Ogre is doing something with it in a different thread.

    You also have a double delete and leave behind a stale pointer in ~VisualizerApplication. Fix it by not making it a singleton. Just... don't use singletons. Ever.

Tags
c++ ogre
Related questions and answers
  • the rigid body object btRigidBody *RigidBody = new btRigidBody(0, MotionState, Shape, LocalInertia); // Store a pointer to the Ogre Node so we can update it later RigidBody-&gt;setUserPointer((void... btRigidBody *RigidBody = new btRigidBody(0, MotionState, Shape, LocalInertia); // Store a pointer to the Ogre Node so we can update it later RigidBody-&gt;setUserPointer((void *) (node)); // Add...); // CReate the rigid body object btRigidBody *RigidBody = new btRigidBody(TMass, MotionState, Shape, LocalInertia); // Store a pointer to the Ogre Node so we can update it later RigidBody-&gt

  • ;myStopwatch.h&gt; // for keeping times #include &lt;myMath.h&gt; // numb_digits() and digit_val(); using namespace std; enum{ NUMB_LINES= 24, SEC= 1000}; // time stuff enum{TIME... all the code: Thanks again! #include &lt;iostream> #include &lt;time.h&gt; // or "ctime" #include &lt;stdio.h&gt; // for #include &lt;cstdlib> // Windows stuff #include &lt;Windows.h&gt; // GOD DAMMNIT WINDOWS WHY???? #include &lt;conio.h&gt; // Ncurses #include<curses.h&gt; // STL stuff #include &lt;algorithm> #include &lt;string> #include &lt;vector> //String/Int conversion

  • i think i just found the solution. 1) the problem is that backbuffer surface and source surface are of different formats - that is why exception was thrown. 2) the image path needed double slash "C...(D3D_SDK_VERSION))) return false; std::wstring wsPath = L"C:\wood.bmp"; // path to the image D3DXIMAGE_INFO Info; if (FAILED(D3DXGetImageInfoFromFile(wsPath.c_str(), &amp;Info...: //================================================================================================================================// including stuff //=================// #include &lt;windows.h&gt; #include &lt;string> #include &lt;d3d9.h&gt; #include

  • I am trying to build and run Doom 3 from the open source release in order to better understand how the engine works. Unfortunately I am not able to run the game from the binary I built. I just get the console, but cannot run the actual game. Here is what I did: Downloaded the source code from the game repo Downloaded and installed the DirectX SDK Purchased, downloaded and installed Doom 3 from... ------ Initializing File System ------ Loaded pk4 C:\Program Files (x86)\Steam\steamapps\common\doom 3\base\game00.pk4 with checksum 0x29cdb978 Loaded pk4 C:\Program Files (x86)\Steam\steamapps\common

  • sorry if it's in the wrong place. SORRY IN ADVANCE FOR THE AMOUNT OF CODE! file that makes the calls: #include &lt;d3d10.h&gt; #include &lt;d3dx10.h&gt; #include "direct3D.h" #include "game.h...; pTransform-&gt;SetMatrix(&amp;matFinal._11); pPass-&gt;Apply(0); device-&gt;DrawIndexed(36, 0, 0); // display the rendered frame swapchain-&gt;Present(0, 0); } // this function sets up...() { } Cube::~Cube() { pBuffer-&gt;Release(); // why does this only work when put here? because it's created here? I thnk so, why not iBuffer though? } void Cube::Draw() { render_frame(); } void Cube

  • I have a simple question. For people that know and built ogre3D from source as a Static library, what is the order of which the libraries should be linked? The libraries I need to be organized are: Ogre Plugins 'libOgreMain.a' Ogre RenderSystems Boost(version 1.47)link Ogre's Dependencies The reason I'm asking is because in the Ogre forums, I have asked about this and didn't get a good reply... yet. The other reason is because even though I link to the boost library, I get this error: undefined reference to '_imp___ZN5boost6thread20hardware_concurrencyEv' My compiler is MinGW

  • (1, &amp;shaderTexture[0]); // Get A Free Texture ID ( NEW ) glBindTexture (GL_TEXTURE_1D, shaderTexture[0]); // Bind This Texture. From Now On It Will Be 1D... &lt; numTriangles; i++) { MD2Triangle* triangle = triangles + i; for(int j = 0; j &lt; 3; j++) { MD2Vertex* v1 = frame1-&gt;vertices + triangle-&gt;vertices[j... = triangles + i; for(int j = 0; j &lt; 3; j++) { MD2Vertex* v1 = frame1-&gt;vertices + triangle-&gt;vertices[j]; MD2Vertex* v2 = frame2-&gt;vertices + triangle-&gt;vertices[j

  • D3DXMATRIX ColladaFileLoader::processMatrix(daeElement* node) { D3DXMATRIX matWorld; daeTArray<daeElementRef> nodeChildren = node-&gt;getChildren(); for (int i = 0; i &lt... = nodeChildren[i]-&gt;getCharData(); stringstream stm(data); stm &gt;&gt; matWorld.m[3][0]; stm &gt;&gt; matWorld.m[3][1]; stm &gt;&gt; matWorld.m[3][2]; matWorld.m...); stm &gt;&gt; matWorld.m[0][0]; stm &gt;&gt; matWorld.m[0][1]; stm &gt;&gt; matWorld.m[0][2]; stm &gt;&gt; matWorld.m[0][3]; } if (type == "rotationY

  • ;fstream> #include &lt;exception> MD2::MD2(const std::string& Path) : m_TextureID(0), m_Scale(1.0f) { std::ifstream File(Path.c_str(), std::iostream::in | std::ifstream::binary...I'm trying to load MD2 models (stolen from Cube) and my loader seems to be loading the models fine, but I can't say the same for the drawing of the model. Here's my code: typedef float vec3_t[3...) + ('D'&lt;&lt;8) + 'I') #define MD2_VERSION 8 class MD2 : public VertexModel { public: MD2(const std::string& Path); ~MD2(); void Draw(timestep_t Time); private

Data information