Crash in dgContactSolver.cpp L: 643

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Crash in dgContactSolver.cpp L: 643

Postby Bird » Tue Dec 03, 2019 9:06 am

Hi Julio,

I'm making stacks of geometry instances and keep getting intermittent crashes. Here's a video of the type of simulation I'm doing

https://www.youtube.com/watch?v=j0FCI05G1fo&feature=youtu.be


Here's the stack dump. I am using the very latest version of Newton on github

******* STACKDUMP *******
stack dump [0] newton-dynamics\dgPhysics\dgContactSolver.cpp L: 643
stack dump [1] newton-dynamics\dgPhysics\dgContactSolver.cpp L: 862
stack dump [2] newton-dynamics\dgPhysics\dgContactSolver.cpp L: 1268
stack dump [3] newton-dynamics\dgPhysics\dgNarrowPhaseCollision.cpp L: 2057
stack dump [4] newton-dynamics\dgPhysics\dgNarrowPhaseCollision.cpp L: 1659
stack dump [5] newton-dynamics\dgPhysics\dgNarrowPhaseCollision.cpp L: 1775
stack dump [6] newton-dynamics\dgPhysics\dgContact.cpp L: 216
stack dump [7] newton-dynamics\dgPhysics\dgWorldDynamicUpdate.cpp L: 398
stack dump [8] newton-dynamics\dgPhysics\dgWorldDynamicUpdate.cpp L: 110
stack dump [9] newton-dynamics\dgPhysics\dgWorld.cpp L: 975
stack dump [10] newton-dynamics\dgCore\dgMutexThread.cpp L: 59
stack dump [11] newton-dynamics\dgCore\dgThread.cpp L: 202
stack dump [12] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\thread L: 40
stack dump [13] minkernel\crts\ucrt\src\appcrt\startup\thread.cpp L: 97
stack dump [14]
stack dump [15]

Exiting after fatal event (FATAL_EXCEPTION). Fatal type: EXCEPTION_ACCESS_VIOLATION
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Crash in dgContactSolver.cpp L: 643

Postby Julio Jerez » Tue Dec 03, 2019 2:49 pm

is this knew? This is one bug that I have not seem in about 10 years.
That should never, ever happens. unless some memory was overrun or something like that/
It is reproducible?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash in dgContactSolver.cpp L: 643

Postby Bird » Tue Dec 03, 2019 5:23 pm

I was hitting it the previous version of Newton that I was using before getting the latest github version

I doesn't not happen all the time. But if I use the "cup" objects in this scene, it pretty much always crashes

https://sketchfab.com/3d-models/tea-set-3e6331747fb84794a35ed869e4f65714

All the objects are Convex Hull collision shapes

Here's some more info from a crash in Debug mode
Attachments
NewtonCrash.jpg
NewtonCrash.jpg (238.58 KiB) Viewed 8853 times
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Crash in dgContactSolver.cpp L: 643

Postby Julio Jerez » Tue Dec 03, 2019 8:20 pm

oh I see, that assert at line line 234 explain it.
Code: Select all
      rowCount = GetJacobianDerivatives(constraintParams, jointInfo, constraint, leftHandSide, rightHandSide, rowCount);
      dgAssert(rowCount <= cluster->m_rowCount);


It is overrunning memory.
can you tell me how you set the scene, or maybe I can set the serialize and you can send me a serialize scene so that I can test.
let me see if serialization is not broken first because I added few thong and may be.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash in dgContactSolver.cpp L: 643

Postby Bird » Sat Jan 18, 2020 1:53 pm

Hi Julio,

Sorry for the delay. My scene creates many 'geometric instances" of an object by reusing the same NewtonCollision object from the body being instanced ....like in the project I just posted in the Gallery.

I just downloaded the latest version of Newton again and am still hitting this problem. But I might have a better diagnostic for you. I'm now getting a crash in the CalculateContactToConvexHullDescrete() function in dgCollisionConvexPolygon.cpp.
Attachments
Newtondebug.jpg
Newtondebug.jpg (193.97 KiB) Viewed 8532 times
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Crash in dgContactSolver.cpp L: 643

Postby Julio Jerez » Sun Jan 19, 2020 10:46 am

these crashes indicate some stack overrun in some function, but when I look at those function
I can't see how this could happens.
are you using continue collsion by any chance?

also you are using an app I can check but if is possible to serialize one of you scene, I can see if the check that serialize is working, soem time as features are added is goes out of sync wit the engine but is eassy to get is working.
if you can serialize one of your scene and load it is the SDK demos, I can check it out

to serialize a scene you use some function liek this
Code: Select all
static void BodySerializationcallback (NewtonBody* const body, void* const bodyUserData, NewtonSerializeCallback serializeCallback, void* const serializeHandle)
{
   // here the use can save information of this body, ex:
   // a string naming the body, 
   // serialize the visual mesh, or save a link to the visual mesh
   // save labels for looking up the body call backs

   // for the demos I will simple write three stream to identify what body it is, the application can do anything
   const char* const bodyIndentification = "gravityBody\0\0\0\0";
   int size = (strlen (bodyIndentification) + 3) & -4;
   serializeCallback (serializeHandle, &size, sizeof (size));
   serializeCallback (serializeHandle, bodyIndentification, size);
}

void SerializedPhysicScene(const char* const name)
{
   NewtonSerializeToFile(m_world, name, BodySerializationcallback , NULL);
}


thsi will produce a binary file that you can load on the demos sandbox.
then you can send that to me for debug.

but first tell if you are using continue collision because for what you describe it seems like you are.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash in dgContactSolver.cpp L: 643

Postby Bird » Sun Jan 19, 2020 11:35 am

Yes, I'm using ContinuousCollisionMode. I have a comment in my code that says you told me to leave it on all the time ... but that was from a couple of years ago probably.

I'll try to serialize the scene later on today. Thanks for the help!
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Crash in dgContactSolver.cpp L: 643

Postby Julio Jerez » Sun Jan 19, 2020 2:15 pm

ha I see, that may be the problem.
yes is said that, I was under the assumption that the CCD will act on small islands.
few thing has change now, before teh engine was forming individual island that that were solve separate. now the engine form one huge island and onel try to separates the CCD, but if a fast body touch teh huge island, this is what is cause the memory to blow up. I need to revise that and use some trick to address that.

But in the mean time that is some you can try,
you can set the number of sub steps by using this call.

disable the CCD and instead use this call when you initialize the engine of on some setup.
you can make an option.
Code: Select all
NewtonSetNumberOfSubsteps (m_world, MAX_PHYSICS_SUB_STEPS);

where MAX_PHYSICS_SUB_STEPS is an integer.

if you make for example NewtonSetNumberOfSubsteps (m_world, 8 );
if will be the same as CCD.
the different that CCD use a variable steps quantized of a facto of dt/8,
while the substeps are fixed.


I would try with MAX_PHYSICS_SUB_STEPS equal 2, 3, or 4
see how that works.

you get much better physics, and the cost is actually not that big, and since you are no doing real time, is not a big problem in your case.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash in dgContactSolver.cpp L: 643

Postby Bird » Sun Jan 19, 2020 6:42 pm

Definitely much more stable with ContinuousCollision off and substeps = 8 but I'm still getting an occasion crash while testing.

I'm having trouble getting SerializedPhysicScene() to work. I'm trying to do the simplest thing possible first so the scene is just a basic cube object. The relevant code I'm using is below and I'm including the output ".bin" file. When I try to deserialize into the NewtonSandbox, it looks it's like it's reading the Newton body okay but it's crashing while try to read the user data in DemoEntityManager::BodyDeserialization ()

Code: Select all
void NewtonEngine::tick(uint32_t frameNumber)
{
   if (currentFrame == 1)
   {
      const char* path = "D:/ActiveWorks/Code/Opensource/latestNewton/newton-dynamics/applications/media/newtonTest.bin";
      NewtonSerializeToFile(world, path, NewtonCallbacks::BodySerializationcallback, NULL);
   }
}

void NewtonCallbacks::BodySerializationcallback(NewtonBody* const body, void* const bodyUserData, NewtonSerializeCallback serializeCallback, void* const serializeHandle)
{
   Renderable* const node = static_cast<Renderable*>(NewtonBodyGetUserData(body));
   
   const char* const bodyIndentification = node->getName().c_str();
   int size = (strlen(bodyIndentification) + 3) & -4;
   serializeCallback(serializeHandle, &size, sizeof(size));
   serializeCallback(serializeHandle, bodyIndentification, size);
}
Attachments
newtonTest.zip
(560 Bytes) Downloaded 371 times
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Crash in dgContactSolver.cpp L: 643

Postby Julio Jerez » Fri Feb 07, 2020 2:37 am

Sorry I was so late.
yes the serialization was broken, the file will not work, but I think I have fix now.
please try again, when you read this.
you need to Get latest. and the way you do it is liek this:

in you app you inset a line like this
Code: Select all
NewtonSerializeToFile(newton, "filename.bin", NULL, NULL);


then you should be able to load that the output scene in the sandbox demos.

you open the sandbox, in the file menu click new and the click Deserialize.
This opens a file browser that let you find the file and load it.

if it load then you can try the scene with problems and see if you can reproduce the bug.
if so you can send to me for debugging.
I suggest try wit a simple scene first.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash in dgContactSolver.cpp L: 643

Postby Bird » Sat Feb 08, 2020 5:45 pm

I just tried downloading the latest version but it will not build out of the box using the applications/demosSandbox/projects/visualStudion_2015

Severity Code Description Project File Line Suppression State
Error LNK1104 cannot open file 'D:\ActiveWorks\Code\Opensource\latestNewton\newton-dynamics\sdk\projects\visualStudio_2015_static_mt\x64\dContainers\Debug\dContainers_d.lib' demosSandBox D:\ActiveWorks\Code\Opensource\latestNewton\newton-dynamics\applications\demosSandbox\projects\visualStudio_2015\LINK 1
Error C1083 Cannot open include file: 'dgTypes.h': No such file or directory dAnimation D:\ActiveWorks\Code\Opensource\latestNewton\newton-dynamics\sdk\dgNewton\Newton.h 29
Error C1083 Cannot open include file: 'dgTypes.h': No such file or directory dModel D:\ActiveWorks\Code\Opensource\latestNewton\newton-dynamics\sdk\dgNewton\Newton.h 29
Error C1083 Cannot open include file: 'dgTypes.h': No such file or directory dCustomJoints D:\ActiveWorks\Code\Opensource\latestNewton\newton-dynamics\sdk\dgNewton\Newton.h 29
Error C1083 Cannot open include file: 'dgTypes.h': No such file or directory dVehicle D:\ActiveWorks\Code\Opensource\latestNewton\newton-dynamics\sdk\dgNewton\Newton.h 29
Error C1083 Cannot open include file: 'dgTypes.h': No such file or directory dContainers D:\ActiveWorks\Code\Opensource\latestNewton\newton-dynamics\sdk\dContainers\dContainersStdAfx.h 29
Error C1083 Cannot open include file: 'dgTypes.h': No such file or directory dScene D:\ActiveWorks\Code\Opensource\latestNewton\newton-dynamics\sdk\dgNewton\Newton.h 29
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Crash in dgContactSolver.cpp L: 643

Postby Julio Jerez » Sat Feb 08, 2020 6:43 pm

oh yes I forget to click push last night after I committed some changes.
I will let you know later when ready.
sorry about thiat.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash in dgContactSolver.cpp L: 643

Postby Bird » Sun Feb 09, 2020 9:50 am

Thanks, the demo sandbox is compiling again. The Serialize/Deserialize works great. The problem I'm having now is that I can't get Newton to crash anymore when Continuous collision is turned off. :)

Newton is still crashing with Continuous Collision turned on though. I've tried to include the serialized scene data but I'm getting an error message -- "Sorry, the board attachment quota has been reached."
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Crash in dgContactSolver.cpp L: 643

Postby Julio Jerez » Sun Feb 09, 2020 1:59 pm

Bird wrote:Thanks, the demo sandbox is compiling again. The Serialize/Deserialize works great. The problem I'm having now is that I can't get Newton to crash anymore when Continuous collision is turned off. :)
I am going to assume thsi is a good thing :D

I went to the forum admin panel and found and attachment quota setting.
was set to 50 mgbytes and double it, please see if this fix it.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash in dgContactSolver.cpp L: 643

Postby Bird » Sun Feb 09, 2020 4:28 pm

Okay, here's the serialized file where Newton will crash when Continuous Collision is turned on. I could probably make a simpler version if you need it. Just let me know. Thanks for the help!
Attachments
newtonTest_cc_on.zip
(154.61 KiB) Downloaded 372 times
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 5 guests

cron