Page 1 of 1

Crash when running btParallelConstraintSolver

Posted: Fri Jul 08, 2011 3:05 pm
by xristos
Hi,

I've linked my app against a debug version of Bullet and I created a test scene that generates a triangle mesh for static collision ground and a bunch of dynamic spheres and boxes.

Everyting works when running Bullet in Single threaded mode. Everything works fine when I make the dispatcher multithreaded. But I crash when I run the solver multithreaded.

I've initialized Bullet the same way its done in the Multithreaded demo, but on first body contact, Bullet crashes in CustomSetupConstraintsTask(). The pfxGetRigidbodyId*() of one of the bodies is invalid (65534).

Code :

Code: Select all

void CustomSetupContactConstraintsTask(
	PfxConstraintPair *contactPairs,uint32_t numContactPairs,
	btPersistentManifold*	offsetContactManifolds,
	TrbState *offsetRigStates,
	PfxSolverBody *offsetSolverBodies,
	uint32_t numRigidBodies,
	float separateBias,
	float timeStep)
{
	for(uint32_t i=0;i<numContactPairs;i++) {
		PfxConstraintPair &pair = contactPairs[i];
		if(!pfxGetActive(pair) || pfxGetNumConstraints(pair) == 0 ||
			((pfxGetMotionMaskA(pair)&PFX_MOTION_MASK_STATIC) && (pfxGetMotionMaskB(pair)&PFX_MOTION_MASK_STATIC)) ) {
			continue;
		}

		uint16_t iA = pfxGetRigidBodyIdA(pair); [color=#FF0000]<< returns bad value, will over shoot offsetSolverBodies[] later on[/color]
		uint16_t iB = pfxGetRigidBodyIdB(pair);
Locals :

numContactPairs 1 unsigned int

- pair {i8data=0x0edadc80 "þÿ" i16data=0x0edadc80 "�ʀĐ" i32data=0x0edadc80 } PfxSortData16 &
+ i8data 0x0edadc80 "þÿ" unsigned char [16]
- i16data 0x0edadc80 "�ʀĐ" unsigned short [8]
[0] 65534 unsigned short
[1] 19 unsigned short
[2] 640 unsigned short
[3] 272 unsigned short
[4] 2 unsigned short
[5] 0 unsigned short
[6] 0 unsigned short
[7] 0 unsigned short
+ i32data 0x0edadc80 unsigned int [4]




Stack :
> app.exe!CustomSetupContactConstraintsTask(PfxSortData16 * contactPairs=0x0edadc80, unsigned int numContactPairs=1, btPersistentManifold * offsetContactManifolds=0x194a0050, TrbState * offsetRigStates=0x1bd3cc70, PfxSolverBody * offsetSolverBodies=0x1412e540, unsigned int numRigidBodies=60, float separateBias=0.10000000, float timeStep=0.016666668) Line 435 + 0x6 bytes C++
app.exe!SolverThreadFunc(void * userPtr=0x1bd10a58, void * lsMemory=0x00000000) Line 536 + 0x46 bytes C++
app.exe!Thread_no_1(void * lpParam=0x1bd10310) Line 69 + 0x15 bytes C++

Re: Crash when running btParallelConstraintSolver

Posted: Fri Jul 08, 2011 3:06 pm
by xristos
I forgot to mention:

Thank you in advance for your help!

Re: Crash when running btParallelConstraintSolver

Posted: Fri Jul 08, 2011 4:49 pm
by xristos
I'm digging in trying to figure out what's causing the crash..

It looks like the RigidBody ID is set to -2 on purpose, but not sure why. I'm still ramp'ing up with Bullet's code.

I do know that the crash is caused by collision between a triangle mesh and a convex hull if that helps anybody.

I've switched to using SequentialThreadConstructionInfo for the solver just to simplify things, but still get the crash.

Anyways, still investigating..

Re: Crash when running btParallelConstraintSolver

Posted: Thu Feb 09, 2012 4:21 pm
by Ganaboy
Hey i have run into similar problem and i have resolved it. Check the issue tracker

http://code.google.com/p/bullet/issues/ ... rt=&id=524

I have put the post there. Let me know if it fixes it.

There are actually 2 - 3 places where u have to put checks, when u have empty scene or empty constraints when using multithreaded lib

Re: Crash when running btParallelConstraintSolver

Posted: Thu Feb 09, 2012 11:18 pm
by kloplop321
Great find Ganaboy :D

Re: Crash when running btParallelConstraintSolver

Posted: Fri Feb 17, 2012 11:17 am
by Yann
Hi,
I'm getting trouble using the multithreaded libraries also, crashing each time I try to use it.
I tried to add the line proposed by Ganaboy, but didn't solved the case for me.
Anyone who managed to make the multithreaded collision/constraint solver work fine ?

Re: Crash when running btParallelConstraintSolver

Posted: Fri Feb 17, 2012 2:13 pm
by Yann
Well, I got something working by adding the following lines in the btParallelCosntraintSolver.cpp, line 1118:

Code: Select all

if(idA<0 || idB<0)
     continue;
But it work only if I disable split islands ( setSplitIslands(false) ), and still it's not really accurate: in one of my tests, I'm using walls made of individuals square blocks. With the btSequentialImpulseConstraintSolver, it works fine, the wall is stable, but with the btParallelConstraintSolver, the wall is completely unstable, and finally fall.
Well, I'll see what I can do to be able to use it with split islands on (when I turn it on, objects don't collide with each others).

Re: Crash when running btParallelConstraintSolver

Posted: Wed Feb 29, 2012 1:47 am
by Erwin Coumans
Do you mind submitting a patch for the changes you discussion in that issue?

http://code.google.com/p/bullet/issues/ ... rt=&id=524

Thanks a lot,
Erwin

Re: Crash when running btParallelConstraintSolver

Posted: Wed Feb 29, 2012 5:07 pm
by Yann
Sure, I'll try to create a reproduction case and submit the patches I have to do to make it work.
I'll let you know about it.