Bullet and OGRE: memory corruption problem

jiandingzhe
Posts: 3
Joined: Tue Jul 05, 2011 2:03 pm

Bullet and OGRE: memory corruption problem

Post by jiandingzhe »

I previously asked this question on OGRE's forum, but some guys there let me ask the question here...

Previously, the problem is about init OGRE's config window, and construction of bullet's btCollisionDispatcher. You may see the old problem at my post on OGRE's forum:
http://www.ogre3d.org/forums/viewtopic.php?f=2&t=65497

I modified the test slightly, the memory corruption changed its place to happen. But it is still related about btCollisionDispatcher, because it won't happen if I don't new btCollisionDispatcher.

If I create the btCollisionDispatcher before initialiseAllResourceGroups, the memory corruption happens inside initialiseAllResourceGroups; if I create it after, the corruption happens inside the OIS system.

Does bullet use strange ways to manage memory??

This is the code:

Code: Select all

TestApp::TestApp():
    oPluginFile("plugins.cfg"),
    oResourceFile("resources.cfg")
{
    
    
    oRoot = new Ogre::Root(oPluginFile);
    buildResources(oResourceFile);

    if (!oRoot->restoreConfig()) throw;

    oWindow = oRoot->initialise(true, "Ogre Bullet TestApp Render Window");


    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    cout<<"#######################################"<<endl
        <<"#--- init physics world in TestApp ---#"<<endl
        <<"#######################################"<<endl;
    btConfig     = new btDefaultCollisionConfiguration();
    btDispatcher = new btCollisionDispatcher(btConfig);
//     btBroadphase = new btDbvtBroadphase();
//     btSolver     = new btSequentialImpulseConstraintSolver();

    buildOIS();

    windowResized(oWindow);
    Ogre::WindowEventUtilities::addWindowEventListener(oWindow, this);
    oRoot->addFrameListener(this);
}
and this is the error message

Code: Select all

*** glibc detected *** /home/yangxi/projects/OgreBulletTest/build/ogrebullettest: free(): corrupted unsorted chunks: 0x000000000093e050 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7703a)[0x7ffff6e7803a]
/usr/local/lib/libOIS-1.3.0.so(_ZN3OIS13LinuxJoyStick9_scanJoysEv+0x843)[0x7ffff7433853]
/usr/local/lib/libOIS-1.3.0.so(_ZN3OIS17LinuxInputManager17_enumerateDevicesEv+0x1b)[0x7ffff742fffb]
/usr/local/lib/libOIS-1.3.0.so(_ZN3OIS12InputManager17createInputSystemERSt8multimapISsSsSt4lessISsESaISt4pairIKSsSsEEE+0x31)[0x7ffff74298c1]
/home/yangxi/projects/OgreBulletTest/build/ogrebullettest(_ZN7TestApp8buildOISEv+0x1f0)[0x417a36]
/home/yangxi/projects/OgreBulletTest/build/ogrebullettest(_ZN7TestAppC1Ev+0x311)[0x417571]
/home/yangxi/projects/OgreBulletTest/build/ogrebullettest(main+0x27)[0x41706b]
/lib64/libc.so.6(__libc_start_main+0xed)[0x7ffff6e2239d]
/home/yangxi/projects/OgreBulletTest/build/ogrebullettest[0x415bd9]
======= Memory map: ========
00400000-00463000 r-xp 00000000 08:07 5636166                            /home/yangxi/projects/OgreBulletTest/build/ogrebullettest
00663000-00664000 rw-p 00063000 08:07 5636166                            /home/yangxi/projects/OgreBulletTest/build/ogrebullettest
00664000-00a13000 rw-p 00000000 00:00 0                                  [heap]
40000000-4007a000 rw-p 00000000 00:00 0 
4007a000-4007c000 r-xs 00000000 08:06 393277                             /tmp/glw6X0er (deleted)
3a4cc00000-3a4cc1f000 r-xp 00000000 08:06 3935845                        /usr/lib64/libopenjpeg.so.3.1.4.0
3a4cc1f000-3a4ce1e000 ---p 0001f000 08:06 3935845                        /usr/lib64/libopenjpeg.so.3.1.4.0
3a4ce1e000-3a4ce20000 rw-p 0001e000 08:06 3935845                        /usr/lib64/libopenjpeg.so.3.1.4.0
3e9f600000-3e9f65a000 r-xp 00000000 08:06 3955728                        /usr/lib64/libXaw7.so.7.0.0
3e9f65a000-3e9f859000 ---p 0005a000 08:06 3955728                        /usr/lib64/libXaw7.so.7.0.0
3e9f859000-3e9f864000 rw-p 00059000 08:06 3955728                        /usr/lib64/libXaw7.so.7.0.0
3ea0600000-3ea0615000 r-xp 00000000 08:06 2490820                        /lib64/libgcc_s-4.6.0-20110530.so.1
3ea0615000-3ea0814000 ---p 00015000 08:06 2490820                        /lib64/libgcc_s-4.6.0-20110530.so.1
3ea0814000-3ea0815000 rw-p 00014000 08:06 2490820                        /lib64/libgcc_s-4.6.0-20110530.so.1
3ea0a00000-3ea0a16000 r-xp 00000000 08:06 2490458                        /lib64/libz.so.1.2.5
3ea0a16000-3ea0c16000 ---p 00016000 08:06 2490458                        /lib64/libz.so.1.2.5
3ea0c16000-3ea0c17000 rw-p 00016000 08:06 2490458                        /lib64/libz.so.1.2.5
3ea1a00000-3ea1a1b000 r-xp 00000000 08:06 3944787                        /usr/lib64/libxcb.so.1.1.0
3ea1a1b000-3ea1c1a000 ---p 0001b000 08:06 3944787                        /usr/lib64/libxcb.so.1.1.0
3ea1c1a000-3ea1c1b000 rw-p 0001a000 08:06 3944787                        /usr/lib64/libxcb.so.1.1.0
3ea1e00000-3ea1e02000 r-xp 00000000 08:06 3942421                        /usr/lib64/libXau.so.6.0.0
3ea1e02000-3ea2002000 ---p 00002000 08:06 3942421                        /usr/lib64/libXau.so.6.0.0
3ea2002000-3ea2003000 rw-p 00002000 08:06 3942421                        /usr/lib64/libXau.so.6.0.0
3ea2600000-3ea2739000 r-xp 00000000 08:06 3945068                        /usr/lib64/libX11.so.6.3.0
3ea2739000-3ea2938000 ---p 00139000 08:06 3945068                        /usr/lib64/libX11.so.6.3.0
3ea2938000-3ea293e000 rw-p 00138000 08:06 3945068                        /usr/lib64/libX11.so.6.3.0
3ea2a00000-3ea2a11000 r-xp 00000000 08:06 3945599                        /usr/lib64/libXext.so.6.4.0
3ea2a11000-3ea2c11000 ---p 00011000 08:06 3945599                        /usr/lib64/libXext.so.6.4.0
3ea2c11000-3ea2c12000 rw-p 00011000 08:06 3945599                        /usr/lib64/libXext.so.6.4.0
3ea3600000-3ea3626000 r-xp 00000000 08:06 3952199                        /usr/lib64/libpng12.so.0.44.0
3ea3626000-3ea3826000 ---p 00026000 08:06 3952199                        /usr/lib64/libpng12.so.0.44.0
3ea3826000-3ea3827000 rw-p 00026000 08:06 3952199                        /usr/lib64/libpng12.so.0.44.0
3ea3a00000-3ea3a96000 r-xp 00000000 08:06 3946993                        /usr/lib64/libfreetype.so.6.6.2
3ea3a96000-3ea3c96000 ---p 00096000 08:06 3946993                        /usr/lib64/libfreetype.so.6.6.2
3ea3c96000-3ea3c9c000 rw-p 00096000 08:06 3946993                        /usr/lib64/libfreetype.so.6.6.2
3ea3e00000-3ea3ee8000 r-xp 00000000 08:06 3935580                        /usr/lib64/libstdc++.so.6.0.16
3ea3ee8000-3ea40e8000 ---p 000e8000 08:06 3935580                        /usr/lib64/libstdc++.so.6.0.16
3ea40e8000-3ea40f0000 r--p 000e8000 08:06 3935580                        /usr/lib64/libstdc++.so.6.0.16
3ea40f0000-3ea40f2000 rw-p 000f0000 08:06 3935580                        /usr/lib64/libstdc++.so.6.0.16
3ea40f2000-3ea4107000 rw-p 00000000 00:00 0 
3ea4200000-3ea4204000 r-xp 00000000 08:06 2490832                        /lib64/libuuid.so.1.3.0
3ea4204000-3ea4403000 ---p 00004000 08:06 2490832                        /lib64/libuuid.so.1.3.0
3ea4403000-3ea4404000 rw-p 00003000 08:06 2490832                        /lib64/libuuid.so.1.3.0
3ea4e00000-3ea4e09000 r-xp 00000000 08:06 3950559                        /usr/lib64/libXrender.so.1.3.0
3ea4e09000-3ea5009000 ---p 00009000 08:06 3950559                        /usr/lib64/libXrender.so.1.3.0
3ea5009000-3ea500a000 rw-p 00009000 08:06 3950559                        /usr/lib64/libXrender.so.1.3.0
3ea5200000-3ea5207000 r-xp 00000000 08:06 3955725                        /usr/lib64/libSM.so.6.0.1
3ea5207000-3ea5406000 ---p 00007000 08:06 3955725                        /usr/lib64/libSM.so.6.0.1
3ea5406000-3ea5407000 rw-p 00006000 08:06 3955725                        /usr/lib64/libSM.so.6.0.1
3ea5600000-3ea5608000 r-xp 00000000 08:06 3955736                        /usr/lib64/libXrandr.so.2.2.0
3ea5608000-3ea5807000 ---p 00008000 08:06 3955736                        /usr/lib64/libXrandr.so.2.2.0
3ea5807000-3ea5808000 rw-p 00007000 08:06 3955736                        /usr/lib64/libXrandr.so.2.2.0
3ea5a00000-3ea5a09000 r-xp 00000000 08:06 3955738                        /usr/lib64/libXcursor.so.1.0.2
3ea5a09000-3ea5c09000 ---p 00009000 08:06 3955738                        /usr/lib64/libXcursor.so.1.0.2
3ea5c09000-3ea5c0a000 rw-p 00009000 08:06 3955738                        /usr/lib64/libXcursor.so.1.0.2
3ea5e00000-3ea5e05000 r-xp 00000000 08:06 3955737                        /usr/lib64/libXfixes.so.3.1.0
Program received signal SIGABRT, Aborted.
0x00007ffff6e362d5 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64        return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
jiandingzhe
Posts: 3
Joined: Tue Jul 05, 2011 2:03 pm

Re: Bullet and OGRE: memory corruption problem

Post by jiandingzhe »

I occasionally found OGRE is using a customized memory allocator "nedmalloc" by default. It's possible that nedmalloc collides with the standard memory allocation. Could Bullet be configured to use different allocators, or I should let OGRE to use the standard allocator?
jiandingzhe
Posts: 3
Joined: Tue Jul 05, 2011 2:03 pm

Re: Bullet and OGRE: memory corruption problem

Post by jiandingzhe »

I've tried to configure OGRE using standard memory allocator, but the memory corruption still happens.