Compound collision problems after upgrading to newer build

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Compound collision problems after upgrading to newer bui

Postby Julio Jerez » Mon Jun 03, 2019 1:53 pm

I can't see the video.
I was using vs 2015, I will try with 2013 tonight
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compound collision problems after upgrading to newer bui

Postby JernejL » Tue Jun 04, 2019 1:16 am

I changed video to unlisted, i mistaken and made it "private":

I just run game and it crashes, 32 bit single, release build.

Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Compound collision problems after upgrading to newer bui

Postby JernejL » Tue Jun 04, 2019 7:48 am

Can you send me the dll that works for you? maybe something strange is happening on my environment / computer.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Compound collision problems after upgrading to newer bui

Postby Julio Jerez » Tue Jun 04, 2019 8:10 am

the thing is that I runit yesterday all day and no crash.
the last nigh I let it run with my visual studio 2013 version and ther was no crash.

no afte see you video, I unzip the file again so get the same dll you are running, and I did the same exact step shown in teh video. run, attach visual studio, and click start button.
and does no cash either, I did it few time and not crash.

I am adding the out trace so that we can recreate it when it happens.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compound collision problems after upgrading to newer bui

Postby Julio Jerez » Tue Jun 04, 2019 9:06 am

ok I added a trace debug code that should trace print to teh output window, the polygon and the information needed to recreate the bug when it happens.

you just sync and run it, then when I crash on the output window will be a message like this

"********* tracing poygon bug ***************"

you get the info bellow that label and list it here, that will be the polygon that cased the crash.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compound collision problems after upgrading to newer bui

Postby JernejL » Tue Jun 04, 2019 12:54 pm

I am building the trunk version of newton from source - release 32 bit single version.

I now pulled to latest changes, and the game now only crashes when it's run without a debugger, i cannot explain this - game standalone will crash, with visual studio or GDB it won't crash.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Compound collision problems after upgrading to newer bui

Postby Julio Jerez » Tue Jun 04, 2019 1:35 pm

Maybe writing the debug log to a file, them we can check if the crash is generated by bad data and rule that out or in. It will try to add the debug test later.
Also I added the debug to the function itself and that might change the generated compiler code.
I will add the debug log to the caller.

You say it crash with Linux also, that is a sign that is not a compiler issue, it must be some code bug.
A buffer over run or something of that nature.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compound collision problems after upgrading to newer bui

Postby Julio Jerez » Tue Jun 04, 2019 5:07 pm

of if you think and run until the crash happen, it will generate a file names: log:txt with this format

    dist: 1.463942
    origin: 0.312527 0.188587 0.462850
    normal: 0.000000 1.000000 0.000000
    points: 3
    p 172.869858 -0.123720 -176.283798
    p -172.869858 -0.123720 176.281845
    p 172.869843 -0.123720 176.281845

    dist: 1.463942
    origin: 0.312527 0.188587 0.462850
    normal: 0.000000 1.000000 0.000000
    points: 3
    p 172.869858 -0.123720 -176.283798
    p -172.869843 -0.123720 -176.283798
    p -172.869858 -0.123720 176.281845

the last polygon should be the one that cause the crash, you can post that file here and I can see what is wrong.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compound collision problems after upgrading to newer bui

Postby Julio Jerez » Tue Jun 04, 2019 11:33 pm

JernejL after you sync, open up file ../sdk\dgPhysics\dgCollisionConvexPolygon.cpp
line 723 and change the #ifdef from zero to 1
committing enabled create a huge text file.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compound collision problems after upgrading to newer bui

Postby JernejL » Wed Jun 05, 2019 1:17 am

Ok, i got a crash when formatting now:

Unhandled exception at 0x678ECAC8 (newton.dll) in tdc.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.


Code: Select all
>   newton.dll!dgCollisionConvexPolygon::CalculateContactToConvexHullDescrete(const dgWorld * const world=0x19476060, const dgCollisionInstance * const parentMesh=0x19476200, dgCollisionParamProxy & proxy={...}) Line 726   C++



call stack:
Code: Select all
    newton.dll!_invoke_watson(pszExpression=0x00000000, pszFunction=0x00000000, pszFile=0x00000000, nLine=0, pReserved=0) Line 132   C++
    newton.dll!_invalid_parameter(pszExpression, pszFunction, pszFile, nLine, pReserved) Line 85   C++
    newton.dll!_invalid_parameter_noinfo() Line 96   C++
    newton.dll!fprintf(str=0x00000000, format=0x642f1f68, ...) Line 55   C
>   newton.dll!dgCollisionConvexPolygon::CalculateContactToConvexHullDescrete(world=0x18986060, parentMesh=0x18986200, proxy={...}) Line 726   C++
    newton.dll!dgWorld::CalculatePolySoupToHullContactsDescrete(proxy={...}) Line 2518   C++
    newton.dll!dgWorld::CalculateConvexToNonConvexContacts(proxy={...}) Line 2404   C++
    newton.dll!dgWorld::ConvexContacts(pair=0x1898fd9c, proxy={...}) Line 1770   C++
    newton.dll!dgWorld::CalculateContacts(pair=0x1898fd9c, threadIndex=0, ccdMode=false, intersectionTestOnly=false) Line 1900   C++
    newton.dll!dgBroadPhase::CalculatePairContacts(pair=0x1898fd9c, threadID=0) Line 1086   C++
    newton.dll!dgBroadPhase::AddPair(contact=0x16413ce0, timestep, threadIndex=0) Line 1135   C++
    newton.dll!dgBroadPhase::UpdateRigidBodyContacts(descriptor=0x154afe18, nodePtr=0x15ff33c0, timeStep=3.95479480e-024, threadID=0) Line 1580   C++
    newton.dll!dgBroadPhase::UpdateRigidBodyContactKernel(context=0x154afe18, node=0x15ff3580, threadID=0) Line 1507   C++
    newton.dll!dgThreadHive::dgWorkerThread::ConcurrentWork(threadId=1679915485) Line 242   C++
    newton.dll!dgThreadHive::dgWorkerThread::Execute(threadId=0) Line 260   C++
    newton.dll!dgThread::dgThreadSystemCallback(threadData=0x164406c4) Line 166   C++
    newton.dll!std::_LaunchPad<std::_Bind<1,void *,void * (__cdecl*const)(void *),dgThread *> >::_Go() Line 187   C++
    newton.dll!_callthreadstartex() Line 376   C
    newton.dll!_threadstartex(ptd) Line 354   C
    kernel32.dll!@BaseThreadInitThunk@12()   Unknown
    ntdll.dll!__RtlUserThreadStart()   Unknown
    ntdll.dll!__RtlUserThreadStart@8()   Unknown



Image

Link to full image: https://i.imgur.com/bcMxwKw.png

I can keep this debug session live and debug any variables / parameters that you might want inspected.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Compound collision problems after upgrading to newer bui

Postby JernejL » Wed Jun 05, 2019 5:17 am

I have no idea what is happening, i tried to run this on another computer i have - and i got no crash.

The crash is pretty obviouly real in visual studio, what's happening here?

I can sometimes also get fpu exceptions:

Code: Select all
Unhandled exception at 0x540919C8 (newton.dll) in tdc.exe: 0xC00002B5:  Multiple floating point traps (parameters: 0x00000000, 0x00009D31).


Could this be somehow relate to me loading newton dynamicly via LoadLibrary and somehow connected with number of cores / threads and their fpu control word?

Edit: no, i get crash with static and dynamic linking ( LoadLibrary and directly dll import )

I suspected that multithreading could be a factor, so i experimented:

NewtonSetThreadsCount with count 1 with callbacks = no crash.
NewtonSetThreadsCount with count 4 with callbacks = crash

I then thought that i might be doing something thread-unsafe inside callbacks that newton calls - so i experimented by commenting out / disabling all my forcetorque and transform callbacks (to ensure i cannot be corrupting anything from there):

NewtonSetThreadsCount with count 1 without callbacks = no crash.
NewtonSetThreadsCount with count 2..4 without callbacks = crash

This could be sort of a issue related to multithreading inside newton - maybe related to async bug that i also reported?

Another theory: could it be something like FPU control word in worker threads being wrong? on windows FPU control word is per-thread and that means that newton would have to call this when creating worker threads.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Compound collision problems after upgrading to newer bui

Postby Julio Jerez » Wed Jun 05, 2019 8:34 am

wait, wait, the crash if correct, the file pointer is NULL because you run with multicores and each core try to open a file that was alread opened by some oethe thread. I forget tto tell you to try with single core for this test.
try setting the number of core count to 1, for the debug, or you can just do this on this function
Code: Select all
void dgWorld::SetThreadsCount (dgInt32 count)
{
   dgThreadHive::SetThreadsCount(count);
}


change to this

Code: Select all
void dgWorld::SetThreadsCount (dgInt32 count)
{
count = 0;
   dgThreadHive::SetThreadsCount(count);
}


function is in file ../newton-dynamics\sdk\dgPhysics\dgWorld.cpp
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compound collision problems after upgrading to newer bui

Postby JernejL » Wed Jun 05, 2019 8:44 am

If i set it to only use 1 core i get no crashes - i posted that (edited my post) - crash only happens with 2 or more cores

I added this:

I suspected that multithreading could be a factor, so i experimented:

NewtonSetThreadsCount with count 1 with callbacks = no crash.
NewtonSetThreadsCount with count 4 with callbacks = crash

I then thought that i might be doing something thread-unsafe inside callbacks that newton calls - so i experimented by commenting out / disabling all my forcetorque and transform callbacks (to ensure i cannot be corrupting anything from there):

NewtonSetThreadsCount with count 1 without callbacks = no crash.
NewtonSetThreadsCount with count 2..4 without callbacks = crash

This could be sort of a issue related to multithreading inside newton - maybe related to async bug that i also reported?

Another theory: could it be something like FPU control word in worker threads being wrong? on windows FPU control word is per-thread and that means that newton would have to call this when creating worker threads.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Compound collision problems after upgrading to newer bui

Postby Julio Jerez » Wed Jun 05, 2019 9:06 am

all thread set the same precision and options float word, I do not think is that.
Code: Select all
void* dgThread::dgThreadSystemCallback(void* threadData)
{
   dgFloatExceptions exception;
   dgSetPrecisionDouble precision;


the crash now is because the debug code is not thread safe, let me make it thread safe, sand by
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compound collision problems after upgrading to newer bui

Postby Julio Jerez » Wed Jun 05, 2019 9:21 am

ok sync and try again, the log is thread safe, it should not crash there.

edit:

NewtonSetThreadsCount with count 1 without callbacks = no crash.
NewtonSetThreadsCount with count 2..4 without callbacks = crash

This could be sort of a issue related to multithreading inside newton - maybe related to async bug that i also reported?


oh thsi could be why I do no get the crash, I am debugging with single thread, whoever I do no get when I run your repro with your dll.
anyway try teh log again maybe we can see if is bad data, or multithreading.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 8 guests

cron