Game Development Community

Profiler bug in precipitation.cc ?

by Markus Nuebel · in Torque Game Engine · 09/26/2004 (12:50 pm) · 3 replies

The function: destroySplash() may lead to a PROFILE_START() call without a matching PROFILE_END() call, resulting in a stack overflow.

Original code:
void Precipitation::destroySplash(Raindrop *drop)
{
   PROFILE_START(PrecipDestroySplash);
   if (drop == mSplashHead)
   {
      mSplashHead = NULL;
      [b]return[/b];
   }
   
   if (drop->nextSplashDrop)
      drop->nextSplashDrop->prevSplashDrop = drop->prevSplashDrop;
   if (drop->prevSplashDrop)
      drop->prevSplashDrop->nextSplashDrop = drop->nextSplashDrop;
   drop->nextSplashDrop = NULL;
   drop->prevSplashDrop = NULL;
   PROFILE_END();
}

Adjustment for matching profiler calls:

void Precipitation::destroySplash(Raindrop *drop)
{
   PROFILE_START(PrecipDestroySplash);
   if (drop == mSplashHead)
   {
      mSplashHead = NULL;
   }
   else
   {
      if (drop->nextSplashDrop)
         drop->nextSplashDrop->prevSplashDrop = drop->prevSplashDrop;
      if (drop->prevSplashDrop)
         drop->prevSplashDrop->nextSplashDrop = drop->nextSplashDrop;
      drop->nextSplashDrop = NULL;
      drop->prevSplashDrop = NULL;
   }
   PROFILE_END();
}

The same occurs in processTick():

void Precipitation::processTick(const Move *)
{
	...
	PROFILE_START(PrecipProcess);
	ShapeBase* camObj = conn->getCameraObject();
	if (!camObj)
		[b]return[/b];

	...
	PROFILE_END();
}

and in renderPrecip(SceneState *state):
void Precipitation::renderPrecip(SceneState *state)
{
   PROFILE_START(PrecipRenderPrecip);

   GameConnection* conn = GameConnection::getServerConnection();
   if (!conn)
      [b]return[/b]; //need connection to server
   ...
   PROFILER_END();
   
  
}
-- Markus

#1
03/26/2005 (12:15 pm)
Good catch..
nothing a couple NICE GOTOS WONT FIX! roxor.
#2
04/02/2005 (2:17 pm)
Noted, thanks for the research! I think it might be already fixed in 1.4 but I'll check.
#3
08/09/2005 (2:23 am)
Ok, fixed in trunk!