Game Development Community

FIXED: Occasional crash in player.cpp

by Sim Ops Studios (#0003) · in Torque Game Engine Advanced · 09/17/2007 (10:46 am) · 0 replies

Just a quick heads-up to the community:

We discovered what we believe to be a race condition in the Player::updateState method. We haven't chased down the underlying causes, but we were able to isolate the problem to around line 1299 of the updateState method:

S32 seq = mDataBlock->actionList[mActionAnimation.action].sequence;
                  F32 pos = mShapeInstance->getPos(mActionAnimation.thread);

                  mShapeInstance->setTimeScale(mActionAnimation.thread, -sLandReverseScale);
                  mShapeInstance->transitionToSequence(mActionAnimation.thread,
                                                       seq, pos, sAnimationTransitionTime, true);

Under high-load (i.e. low-framerate) conditions, we ocasionally reach this code when mActionAnimation.action is still PlayerData::NullAnimation. Wrapping this code in a check for the bad case avoids a crash on attempting to access the 511th array element of actionList.

If anyone else has seen this issue and has insight regarding the underlying causes of the race condition, it would be very welcome. I want to avoid spackling over an issue like this with a sanity-check, but I can't seem to isolate what would cause the action field to still be NullAnimation at this phase in the game.