Painting crash

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Painting crash

Postby Bird » Mon Dec 08, 2014 6:26 pm

Hi Julio,

I'm hitting a hard to diagnose crash in Newton while painting using a phantom(Kinematic) body as in the sandbox Kinematic demo.

The crash happens as different places in Newton but it always seems to be in code relating to Contacts. Here's a video http://hurleyworks.com/media/flash/PaintCrash/PaintCrash.html

Feels like it might be a multi-threading issue to me. I create all my new bodies on Newton's thread in a NewtonListener callback but I make calls to NewtonBodySetMatrix, NewtonCollisionClosestPoint, NewtonWorldForEachBodyInAABBDo and NewtonCollisionIntersectionTest from LightWave's thread.

Is it safe to make those calls from another thread or do they have to be on Newton's thread too?

-Bird
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Painting crash

Postby Julio Jerez » Mon Dec 08, 2014 6:38 pm

NewtonBodySetMatrix Is the only one that may case problems
are you doing that concurrent with the update?

what it crash again see of any other thread is also working on the same broaphsope
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Painting crash

Postby Bird » Mon Dec 08, 2014 10:42 pm

Julio Jerez wrote:NewtonBodySetMatrix Is the only one that may case problems
are you doing that concurrent with the update?

what it crash again see of any other thread is also working on the same broaphsope


Yes, I'm calling NewtonBodySetMatix to set the transform of the phantom body while the engine is updating. But I moved it into the NewtonListenerCallback so it's running on Newton's thread and there's still crashing.

I'm not very proficient at multi-threaded debugging. But I captured the vs2013 Parallel Stack map for 6 different crashes.http://hurleyworks.com/downloads/PaintCrash.zip ... maybe you can figure it what it means. :)

I did find a useful presentation from MS about debugging in vs2013. The multi-threading stuff is in the last quarter or so
http://events.visualstudio.com/eng/teched-north-america-2014/sessions-day-1/debugging-tips-and-tricks-in-visual-studio-2013/

Bird
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Painting crash

Postby Bird » Tue Dec 09, 2014 7:27 am

I found it I hope. The main thread call stack at the time of a crash shows I was making calls to NewtonBodySetCollisionScale, NewtonBodySetMassProperties and NewtonBodySetForce at that time. I forgot that I had added a function so that users could rescale bodies while the simulation was running.

There's no more crashing if I stop making that call to update body properties. Do you think that was was the problem? Or did I just hide it again by changing the timing?

Once I learned a bit more how to use them, the vs 2013 Parallel Watch and Stack windows were incredibly helpful :)

-Bird
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Painting crash

Postby Julio Jerez » Tue Dec 09, 2014 11:26 am

oh yes that function will definitely cause a guarantee crash if called for a newton update
The reason is that is destroy the contact joint explicitly,
Code: Select all
void NewtonBodySetCollisionScale (const NewtonBody* const bodyPtr, dFloat scaleX, dFloat scaleY, dFloat scaleZ)
{
///
   NewtonJoint* nextJoint;
   for (NewtonJoint* contactJoint = NewtonBodyGetFirstContactJoint(bodyPtr); contactJoint; contactJoint = nextJoint) {
      nextJoint = NewtonBodyGetNextContactJoint(bodyPtr, contactJoint);

// this is what cause the crash
      world->DestroyConstraint ((dgConstraint*)contactJoint);
   }
 


I have struggled to get to be re-entrant but is always a problem by adding a world->Sync(), because
but for that the semaphores have to use real mutexes with will make engine thread system several order of magnitude slower and prone to stuttering.

I made a change the make the function no destructive, instead of destroying the contact which is what causes the guarantee crash, I simple disable it.
Please try Sync and try again. That function should not crash the engine under any circumstances.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Painting crash

Postby Bird » Tue Dec 09, 2014 1:22 pm

I made a change the make the function no destructive, instead of destroying the contact which is what causes the guarantee crash, I simple disable it.
Please try Sync and try again. That function should not crash the engine under any circumstance


Excellent! Works fine now.

Thanks very much!

-Bird
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 1 guest