Crash in btPoolAllocator?

jackjohnson
Posts: 8
Joined: Tue Sep 23, 2008 10:07 am

Crash in btPoolAllocator?

Post by jackjohnson »

Hi All,

I'm fairly new to bullet SDK. I have a sphere object that collides with a static concave mesh.

About 50% of the time this collision takes place okay. Then if I try to run the simulation again, I get different results, but the same crash thread on every crash. An EXC_BAD_ACCESS...

Can anyone shed any light on what problem I am looking at here...in the CONSOLE:

Crash takes place on line: m_firstFree = *(void**)m_firstFree;

Code: Select all

void*	allocate(int size)
	{
		// release mode fix
		(void)size;
		btAssert(!size || size<=m_elemSize);
		btAssert(m_freeCount>0);
        void* result = m_firstFree;
        m_firstFree = *(void**)m_firstFree;
        --m_freeCount;
        return result;
	}
And here is the console:

Code: Select all

0 btPoolAllocator::allocate
1 btCollisionDispatcher::getNewManifold
2 btConvexTriangleCallback::btConvexTriangleCallback
3 btConvexConcaveCollisionAlgorithm::btConvexConcaveCollisionAlgorithm
4 btConvexConcaveCollisionAlgorithm::CreateFunc::CreateCollisionAlgorithm
5 btCollisionDispatcher::findAlgorithm
6 btCollisionDispatcher::defaultNearCallback
7 btCollisionPairCallback::processOverlap
8 btHashedOverlappingPairCache::processAllOverlappingPairs
9 btCollisionDispatcher::dispatchAllCollisionPairs
10 btCollisionWorld::performDiscreteCollisionDetection
11 btDiscreteDynamicsWorld::internalSingleStepSimulation
12 btSoftRigidDynamicsWorld::internalSingleStepSimulation
13 btDiscreteDynamicsWorld::stepSimulation
14 sio2PhysicRender

//I am using a 3d graphics engine sio2Interactive...
Does the crash have something to do with my callback functions?

I'm so confused. Any help would be greatly appreciated.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Crash in btPoolAllocator?

Post by Erwin Coumans »

jackjohnson wrote:Does the crash have something to do with my callback functions?
Which callback function? Are you adding/removing objects during a callback? That is not supported/allowed.

Hope this helps,
Erwin
jackjohnson
Posts: 8
Joined: Tue Sep 23, 2008 10:07 am

Re: Crash in btPoolAllocator?

Post by jackjohnson »

.
Last edited by jackjohnson on Tue Nov 11, 2008 10:18 pm, edited 1 time in total.
jackjohnson
Posts: 8
Joined: Tue Sep 23, 2008 10:07 am

Re: Crash in btPoolAllocator?

Post by jackjohnson »

One more quick question:

I found this in another post:
I need to place them in a "safe" location where they don't overlap together. This is a complicated problem due to
multiple collisions and I was wondering if Bullet provides any functionality for this
It appears my sphere may be colliding with more than 1 object in the same vicinity.

Would this cause the crash outlined above? If so, do I need to space my targets farther apart to prevent this in the simulation?

I am not adding./removing any objects during the callback. These collisions seem to work about 30-40% of the time, and the rest crash with the same trace.

I'm at a loss of how to trace the source of the error.

Here is a more detailed crash trace:

Code: Select all

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000041dccccd
Crashed Thread:  0

Thread 0 Crashed:
0   tutorial08                    	0x0017d72a btPoolAllocator::allocate(int) + 164 (btPoolAllocator.h:66)
1   tutorial08                    	0x0017d417 btCollisionDispatcher::getNewManifold(void*, void*) + 103 (btCollisionDispatcher.cpp:86)
2   tutorial08                    	0x001609cc btConvexTriangleCallback::btConvexTriangleCallback(btDispatcher*, btCollisionObject*, btCollisionObject*, bool) + 194
3   tutorial08                    	0x00160a71 btConvexConcaveCollisionAlgorithm::btConvexConcaveCollisionAlgorithm(btCollisionAlgorithmConstructionInfo const&, btCollisionObject*, btCollisionObject*, bool) + 107
4   tutorial08                    	0x00153f96 btConvexConcaveCollisionAlgorithm::SwappedCreateFunc::CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo&, btCollisionObject*, btCollisionObject*) + 108 (btConvexConcaveCollisionAlgorithm.h:109)
5   tutorial08                    	0x0017ca50 btCollisionDispatcher::findAlgorithm(btCollisionObject*, btCollisionObject*, btPersistentManifold*) + 132 (btCollisionDispatcher.cpp:139)
6   tutorial08                    	0x0017ccb3 btCollisionDispatcher::defaultNearCallback(btBroadphasePair&, btCollisionDispatcher&, btDispatcherInfo const&) + 121 (btCollisionDispatcher.cpp:253)
7   tutorial08                    	0x0017d96a btCollisionPairCallback::processOverlap(btBroadphasePair&) + 50 (btCollisionDispatcher.cpp:221)
8   tutorial08                    	0x00117f44 btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback*, btDispatcher*) + 72 (btOverlappingPairCache.cpp:375)
9   tutorial08                    	0x0017cc08 btCollisionDispatcher::dispatchAllCollisionPairs(btOverlappingPairCache*, btDispatcherInfo const&, btDispatcher*) + 64 (btCollisionDispatcher.cpp:233)
10  tutorial08                    	0x0016b4d4 btCollisionWorld::performDiscreteCollisionDetection() + 274 (btCollisionWorld.cpp:177)
11  tutorial08                    	0x0015b708 btDiscreteDynamicsWorld::internalSingleStepSimulation(float) + 136 (btDiscreteDynamicsWorld.cpp:378)
12  tutorial08                    	0x000e2652 btSoftRigidDynamicsWorld::internalSingleStepSimulation(float) + 24 (btSoftRigidDynamicsWorld.cpp:55)
13  tutorial08                    	0x00155f5c btDiscreteDynamicsWorld::stepSimulation(float, int, float) + 426 (btDiscreteDynamicsWorld.cpp:345)
14  tutorial08                    	0x000387a4 sio2PhysicRender(SIO2physic*, SIO2window*) + 102

User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Crash in btPoolAllocator?

Post by Erwin Coumans »

Again, which callback function? Are you adding/removing objects during a callback? That is not supported/allowed.

What version of Bullet are you using? Has it be modified at all?

Can you check Bullet/src/BulletCollision/CollisionDispatch/btDefaultCollisionConstructionInfo.h, what are the values for m_defaultMaxCollisionAlgorithmPoolSize?

Code: Select all

btDefaultCollisionConstructionInfo()
		:m_stackAlloc(0),
		m_persistentManifoldPool(0),
		m_collisionAlgorithmPool(0),
		m_defaultMaxPersistentManifoldPoolSize(4096),
		m_defaultMaxCollisionAlgorithmPoolSize(4096),
		m_defaultStackAllocatorSize(0)
	{
	}
It appears my sphere may be colliding with more than 1 object in the same vicinity.
Would this cause the crash outlined above?
No, that is not related.

If you reproduce this in debug mode, can you report the values for m_freeCount , m_firstFree, size and m_elemSize at the time of the crash?

Hope this helps,
Erwin
igostavro
Posts: 2
Joined: Sun Nov 22, 2009 11:43 pm

Re: Crash in btPoolAllocator?

Post by igostavro »

I am getting the same crash:

void* allocate(int size)
{
// release mode fix
(void)size;
btAssert(!size || size<=m_elemSize);
btAssert(m_freeCount>0);
void* result = m_firstFree;
m_firstFree = *(void**)m_firstFree; <------
///crash output for above line: 0xC0000005: Access violation reading location 0xbed25b2b.
///
--m_freeCount;
return result;
}


size = 736
m_elemSize = 736
m_freeCount = 4082
m_firstFree = 0xbed25b2b

call stack:

> !btPoolAllocator::allocate(int size=736) Line 67 + 0x9 bytes C++
!btCollisionDispatcher::getNewManifold(void * b0=0x0f5a2c90, void * b1=0x16e066d0) Line 88 + 0x13 bytes C++
!btConvexTriangleCallback::btConvexTriangleCallback(btDispatcher * dispatcher=0x02e72f50, btCollisionObject * body0=0x0f5a2c90, btCollisionObject * body1=0x16e066d0, bool isSwapped=false) Line 59 + 0x21 bytes C++
!btConvexConcaveCollisionAlgorithm::btConvexConcaveCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo & ci={...}, btCollisionObject * body0=0x0f5a2c90, btCollisionObject * body1=0x16e066d0, bool isSwapped=false) Line 34 C++
!btConvexConcaveCollisionAlgorithm::CreateFunc::CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo & ci={...}, btCollisionObject * body0=0x0f5a2c90, btCollisionObject * body1=0x16e066d0) Line 101 + 0x2d bytes C++
!btCollisionDispatcher::findAlgorithm(btCollisionObject * body0=0x0f5a2c90, btCollisionObject * body1=0x16e066d0, btPersistentManifold * sharedManifold=0x00000000) Line 141 + 0x4a bytes C++
!btCollisionDispatcher::defaultNearCallback(btBroadphasePair & collisionPair={...}, btCollisionDispatcher & dispatcher={...}, const btDispatcherInfo & dispatchInfo={...}) Line 255 + 0x17 bytes C++
!btCollisionPairCallback::processOverlap(btBroadphasePair & pair={...}) Line 221 + 0x1f bytes C++
!btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback * callback=0x0012f128, btDispatcher * dispatcher=0x02e72f50) Line 383 + 0x11 bytes C++
!btCollisionDispatcher::dispatchAllCollisionPairs(btOverlappingPairCache * pairCache=0x02e74150, const btDispatcherInfo & dispatchInfo={...}, btDispatcher * dispatcher=0x02e72f50) Line 239 C++
!btCollisionWorld::performDiscreteCollisionDetection() Line 188 C++
!btDiscreteDynamicsWorld::internalSingleStepSimulation(float timeStep=0.016666668) Line 389 C++
!btDiscreteDynamicsWorld::stepSimulation(float timeStep=0.016666668, int maxSubSteps=1, float fixedTimeStep=0.016666668) Line 356 C++




Any Ideas?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Crash in btPoolAllocator?

Post by Erwin Coumans »

If you can provide us with a reproduction case, we can look into it.

Can you modify any of the Bullet demos to reproduce this?
Thanks,
Erwin
igostavro
Posts: 2
Joined: Sun Nov 22, 2009 11:43 pm

Re: Crash in btPoolAllocator?

Post by igostavro »

Thanks for responding.

I just resolved the issue. We were destroying a physics shape in the middle of a physics callback into the game-code. Once I deferred the destruction to after the physics world update, the crash disappeared.

Hope this helps others who come across this crash.