SimpleScenes_Zombie Crashes at Shutdown (SOLVED)

Orange

05-06-2012 12:48:36

When I compile and run the SimpleScenes_Zombie, it runs ok, but when changing scenes or shutting down the app it causes an unknown crash. I think it may have to do with the destructor not properly destroying the myRagDolls, but I'm not sure how to do this correctly.

This problem also happens whenever simpleScenes::createRagdoll() makes a Ragdoll, again it crashes at shutdown.

Does anyone know of a solution to fixing this error or a work around?

Orange

05-06-2012 13:35:12

for( RagDollList::iterator zE = myRagDolls.begin();
zE != myRagDolls.end(); ++zE )
{
assert((* zE )->getParentNode() );
assert((* zE )->getParentNode()->getParent() );

( static_cast< SceneNode *>
((* zE )->getParentNode()->getParent() ))->removeAndDestroyChild(
(*zE )->getParentNode()->getName() );

_mgr->destroyMovableObject((* zE )->getName(),
OgreOde_Prefab::RagdollFactory::FACTORY_TYPE_NAME );
}


When I comment out this section of code from the destructor, I can change scenes without crash as long as I don't try to reload the ragdoll scene. I can also shutdown without crash. I'm not sure what is wrong with it yet, so if you see the issue please make a note here in the reply's.

dermont

05-06-2012 18:07:21

From backtrace on Linux it appears related to memory allocation and crashes on freeing the BoneWorldMatrices.


if (mSkeletonInstance) {
OGRE_FREE_SIMD(mBoneWorldMatrices, MEMCATEGORY_ANIMATION);



Program received signal SIGABRT, Aborted.
0xb7fdd424 in __kernel_vsyscall ()
(gdb) bt
#0 0xb7fdd424 in __kernel_vsyscall ()
#1 0xb75cf1ef in __GI_raise (sig=6)
at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2 0xb75d2835 in __GI_abort () at abort.c:91
#3 0xb7c8a6bc in nedalloc::nedblksize (mem=mem@entry=0x89404d0)
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/src/nedmalloc/nedmalloc.c:143
#4 0xb7c8b53c in nedalloc::nedpfree (p=0xb7fd5840, p@entry=0x0,
mem=mem@entry=0x89404d0)
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/src/nedmalloc/nedmalloc.c:849
#5 0xb7c8b773 in nedalloc::nedfree (mem=mem@entry=0x89404d0)
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/src/nedmalloc/nedmalloc.c:155
#6 0xb7c8c268 in Ogre::_NedPoolingIntern::internalFree (
a_mem=a_mem@entry=0x89404d0)
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/src/OgreMemoryNedPooling.cpp:134
#7 0xb7c90baf in Ogre::NedPoolingImpl::deallocBytesAligned (align=0,
---Type <return> to continue, or q <return> to quit---
ptr=0x89404d0)
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/src/OgreMemoryNedPooling.cpp:190
#8 0xb7c2d68b in deallocateBytes (ptr=<optimized out>)
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/include/OgreMemoryNedPooling.h:118
#9 _deinitialise (this=0xb1b1a704)
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/src/OgreEntity.cpp:262
#10 Ogre::Entity::_deinitialise (this=0xb1b1a704)
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/src/OgreEntity.cpp:220
#11 0xb7c3a01c in Ogre::Entity::~Entity (this=0xb1b1a704,
__in_chrg=<optimized out>)
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/src/OgreEntity.cpp:304
#12 0xb78ad9a2 in OgreOde_Prefab::Ragdoll::~Ragdoll (this=0xb1b1a6f8,
__in_chrg=<optimized out>) at OgreOdeRagdoll.cpp:690
#13 0xb78adab2 in OgreOde_Prefab::Ragdoll::~Ragdoll (this=0xb1b1a6f8,
__in_chrg=<optimized out>) at OgreOdeRagdoll.cpp:698
#14 0xb78abfb3 in OgreOde_Prefab::RagdollFactory::destroyInstance (
this=0xb62e14a8, obj=0xb1b1a704) at OgreOdeRagdoll.cpp:738
---Type <return> to continue, or q <return> to quit---
#15 0xb7da8308 in Ogre::SceneManager::destroyMovableObject (this=0xb6cee950,
name=..., typeName=...)
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/src/OgreSceneManager.cpp:6816
#16 0x08067fe8 in SimpleScenes::~SimpleScenes (this=0x889b998,
__in_chrg=<optimized out>) at SimpleScenes.cpp:358
#17 0x08058ccd in ~SimpleScenes_BoxStack (this=0x889b998,
__in_chrg=<optimized out>) at ../include/SimpleScenes_BoxStack.h:18
#18 SimpleScenes_BoxStack::~SimpleScenes_BoxStack (this=0x889b998,
__in_chrg=<optimized out>) at ../include/SimpleScenes_BoxStack.h:18
#19 0x08056e37 in SimpleScenesApplication::frameEnded (this=0xbffff29c,
evt=..., myInput=0x85b0868, mMouse=0x609a)
at SimpleScenesApplication.cpp:354
#20 0x08057429 in SimpleScenesFrameListener::frameEnded (this=0x85b0698,
evt=...) at SimpleScenesApplication.cpp:103
#21 0xb7da0fb1 in Ogre::Root::_fireFrameEnded (this=this@entry=0xb6ce0260,
evt=...)
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/src/OgreRoot.cpp:864
#22 0xb7da16c2 in Ogre::Root::_fireFrameEnded (this=this@entry=0xb6ce0260)
---Type <return> to continue, or q <return> to quit---
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/src/OgreRoot.cpp:903
#23 0xb7da188c in Ogre::Root::renderOneFrame (this=this@entry=0xb6ce0260)
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/src/OgreRoot.cpp:981
#24 0xb7da18e5 in Ogre::Root::startRendering (this=0xb6ce0260)
at /home/dermont/Development/OGRE/src/v1-8/OgreMain/src/OgreRoot.cpp:968
#25 0x0805801b in go (this=0xbffff29c)
at /home/dermont/Development/OGRE/sdk/v1-8/include/OGRE/ExampleApplication.h:164
#26 ExampleApplication::go (this=0xbffff29c)
at /home/dermont/Development/OGRE/sdk/v1-8/include/OGRE/ExampleApplication.h:159
#27 0x08055028 in main (argc=1, argv=0xbffff384)
at SimpleScenesApplication.cpp:38


OgreEntity.cpp

if (mSkeletonInstance) {
OGRE_FREE_SIMD(mBoneWorldMatrices, MEMCATEGORY_ANIMATION);


Looking at the entity source code try updating OgreOdeRagdoll.cpp (line 83):

if (!mBoneWorldMatrices)
{
mBoneWorldMatrices =
static_cast<Matrix4*>(OGRE_MALLOC_SIMD(sizeof(Matrix4) * mNumBoneMatrices, MEMCATEGORY_ANIMATION));

// mBoneWorldMatrices =
// static_cast<Matrix4*>(Ogre::AlignedMemory::allocate(sizeof(Matrix4) * mNumBoneMatrices));
}

Orange

06-06-2012 02:31:20

Thanks for your assistance. I'll see if I can manage to update my project soon.

Orange

06-06-2012 03:12:07

**UPDATE**

Dermont thanks again for your pro insight. I can't make heads or tails of VS 2010's debugger speak, so tracing the root of the issue was not possible for me. I couldn't even figure out how to step into the actual breakpoints I set up in the destructor, nor understand what it was telling me.

By updating OgreOdeRagdoll.cpp with your fix, I can now shoot the robots and zombies the way the demo was meant to be demonstrated.

DERMONT RULES!!! XD