Crash when running btParallelConstraintSolver

Post Reply
xristos
Posts: 11
Joined: Wed Jun 22, 2011 3:15 pm

Crash when running btParallelConstraintSolver

Post 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++
xristos
Posts: 11
Joined: Wed Jun 22, 2011 3:15 pm

Re: Crash when running btParallelConstraintSolver

Post by xristos »

I forgot to mention:

Thank you in advance for your help!
xristos
Posts: 11
Joined: Wed Jun 22, 2011 3:15 pm

Re: Crash when running btParallelConstraintSolver

Post 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..
Ganaboy
Posts: 1
Joined: Wed Feb 08, 2012 11:02 am

Re: Crash when running btParallelConstraintSolver

Post 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
kloplop321
Posts: 55
Joined: Sun Jan 01, 2012 7:37 pm

Re: Crash when running btParallelConstraintSolver

Post by kloplop321 »

Great find Ganaboy :D
User avatar
Yann
Posts: 52
Joined: Wed Sep 28, 2011 8:36 am
Location: France
Contact:

Re: Crash when running btParallelConstraintSolver

Post 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 ?
User avatar
Yann
Posts: 52
Joined: Wed Sep 28, 2011 8:36 am
Location: France
Contact:

Re: Crash when running btParallelConstraintSolver

Post 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).
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Crash when running btParallelConstraintSolver

Post 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
User avatar
Yann
Posts: 52
Joined: Wed Sep 28, 2011 8:36 am
Location: France
Contact:

Re: Crash when running btParallelConstraintSolver

Post 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.
Post Reply