btQuaternion is causing a floating point exception??

Post Reply
K6L2
Posts: 7
Joined: Mon May 11, 2015 9:43 pm

btQuaternion is causing a floating point exception??

Post by K6L2 »

The version of Bullet I'm running is 283, which if I recall correctly is relatively recent. I did some google searching briefly and found several issues on their tracker in the distant pass about this function too.

What's strange about this is that it only seems happens when I'm building in release mode in mingw, which uses -O2. Or at least, I haven't had it happen in debug mode yet I don't think... Needless to say it makes finding all the details about what is going on to cause this very difficult, as the variables in this function keep getting optimized out in gdb it seems...

The offending line of code (where the floating point exception is getting fired) is this one (inside of btQuaternion slerp, of course):

Code: Select all

const btScalar d = btScalar(1.0) / btSin(theta);
Possibly division by zero? gdb isn't being very helpful honestly...
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: btQuaternion is causing a floating point exception??

Post by Basroil »

Sounds like intrinsics and optimization are removing protections somewhere? Might as well try to disable optimizations for the line:

Code: Select all

if (btFabs(product) < btScalar(1))
Since theta is an arc cosine and the product is between -1 and 1 exclusive, it should never be going to zero unless (sign*product) is being truncated or rounded to zero or the math library used does not fit IEEE specifications.

Not sure what debugger you're using, but Visual Studio lets you debug optimized files by making a map that lets you view optimized code along side the closest point in source code. Perhaps your debugger has a similar feature. Disassembly is also an option, but unless you like seeing register movement and xmm commands all over the place, it might be harder to pinpoint what's going on.
K6L2
Posts: 7
Joined: Mon May 11, 2015 9:43 pm

Re: btQuaternion is causing a floating point exception??

Post by K6L2 »

Ugh... I don't want to do that though, someone else please do instead lol.

For the record I seem to have fixed the bug by checking to see if the angle between the quaternions was > 0.001 (some small float) instead of > 0 before calling the slerp function.
Post Reply