Unbelievably, this little thing causes a crash...

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Unbelievably, this little thing causes a crash...

Postby misho » Wed Oct 24, 2018 3:05 pm

I've been debugging this nasty crash, which proved to be an incredibly annoying little bug.

Basically, I have a setup that saves and loads Newton bodies in 3D space, and one of the parameters is the body's attitude, represented as a Quaternion, with 4 Quaternion parameters listed. I save the file in txt format (I want my users to be able to edit it) and then I read and re-load objects and position and orient them according to the parameters. So, on one occasion, I saved just such a file, and while re-loading it, I get a nasty crash deep inside Newton. After a few hours of debugging, I narrowed it down:

Code: Select all
// This line works fine when loaded
attitude=   -0.188616, 0.738900, 0.626815, -0.159867

// This line results in a fatal crash
attitude=   -0.188616, 0.738901, 0.626815, -0.159867


Can you spot the difference? Yup... it is a 0.000001 difference in the 2nd parameter.

I have no idea how to debug this, nor would I even to begin to contemplate debugging the inner workings of Newton. Can anything be done to prevent this, put some recoverable checks? All I can do is supply a call stack upon crash.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Unbelievably, this little thing causes a crash...

Postby Dave Gravel » Wed Oct 24, 2018 3:48 pm

Do you use Async update ?
If yes maybe you need to call NewtonWaitForUpdateToFinish somewhere before load the saved data from runtime.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Unbelievably, this little thing causes a crash...

Postby Sweenie » Wed Oct 24, 2018 4:34 pm

Try normalizing the Quaternion after you read the values from the file. Just a guess though.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Unbelievably, this little thing causes a crash...

Postby misho » Thu Oct 25, 2018 4:04 pm

Dave Gravel wrote:Do you use Async update ?
If yes maybe you need to call NewtonWaitForUpdateToFinish somewhere before load the saved data from runtime.


No, I do not - I have pausing functionality that doesn't work well with Async... but thanks, though!
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Unbelievably, this little thing causes a crash...

Postby misho » Thu Oct 25, 2018 4:11 pm

Sweenie wrote:Try normalizing the Quaternion after you read the values from the file. Just a guess though.


And that was a good guess, sir! It worked! Thanks a bunch! :mrgreen:
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 2 guests

cron