Game Development Community

Lockup (endless loop) in Container::castRay(), and possible fix

by Ed Zavada · in Torque Game Engine · 08/16/2007 (1:58 pm) · 4 replies

I've been getting occasional lockups when I play a death animation in TGE 1.5.2. I finally managed to catch it in the debugger, and found that Death::fallToGround() calls Container::castRay(), which then gets stuck in an endless loop because a while loop compares to NAN values.

I'm attempting to fix this in sceneObject.cc by changing the following in Container::castRay (approx line 1352) :

while (currStartX != normalEnd.x)
to
while ( (currStartX != normalEnd.x) && (currStartX == currStartX) )

Since NAN is not equal to itself, this should detect currStartX = NAN and break out of the loop. However, if anyone has any insight into how this could happen in the first place, or whether there are repercussions to this change, I would appreciate hearing about it.

#1
09/12/2007 (7:00 am)
This has definitely fixed the occasional lockups with death animations. We haven't seen this since the code chance was applied.
#2
09/12/2007 (9:02 am)
Good to know.
#3
09/12/2007 (9:30 am)
Hey Ed,

This is a good idea, thanks for sharing.

We have added your code change as an assert in debug builds so that we can hopefully track down the source of any NANs that occur.

Todd
#4
09/12/2007 (2:38 pm)
I experienced a similar situation with NANs and castRay, although the root of the problem was located elsewhere.

There's a good thread that deals with this and may help you track down where exactly the NAN is originally caused. Specifically the last post by Nicolas Quijano.

www.garagegames.com/mg/forums/result.thread.php?qt=28092