Skip to content

Possible issues in W3DDisplay debug feature #3261

Description

@stephanmeesters
 else if ( TheGlobalData->m_dumpStatsAtInterval && TheGameLogic->getGameMode() <= GAME_REPLAY )
  {
    Int interval = TheGlobalData->m_statsInterval;
    if ( TheGameLogic->getFrame() > 0 && (TheGameLogic->getFrame() % interval) == 0 )

Zero interval crashes

In a debug performance-statistics build, -stats 0 or a nonnumeric value enables periodic dumping with an interval of zero because the command-line parser uses atoi without validation. This line then evaluates frame % 0, crashing the game once the frame count is positive. Validate the interval before enabling periodic dumps or guard it here.


    if ( TheGameLogic->getFrame() > 0 && (TheGameLogic->getFrame() % interval) == 0 )
    {
  	  TheStatDump.dumpStats( TRUE, TRUE );
    	TheInGameUI->message( L"-stats is running, at interval: %d.", TheGlobalData->m_statsInterval );

The periodic check is level-triggered on the logic-frame number, so every render while one divisible
logic frame is current writes and flushes another complete dump and posts another UI message.
Rendering can run multiple times between logic updates, producing duplicate records and potentially
severe disk and UI spam when logic is throttled or stopped.


											draw->getPosition()->z
											);

			const PhysicsBehavior *physics = obj->getPhysics();

Nullable object is dereferenced

A selected or moused-over drawable is not guaranteed to have a backing logic object, as shown by the existing obj null check immediately above. The new physics lookup dereferences obj unconditionally, so inspecting an unbound presentation-only drawable in the debug statistics display can crash. Guard obj before calling getPhysics().


	fprintf( m_fp, "    -Slowest 2 scripts %s\n", slowScripts.str() );
	fprintf( m_fp, "    -Slowest 2 scripts      %s\n", slowScripts.str() );
	fprintf( m_fp, "    -Slowest 2 script times %.5f msec, %.5f msec \n", slowScript1*1000, slowScript2*1000 );
  if ( flagSpikes && slowScript1*1000 > 0.2f || slowScript2*1000 > 0.2f )

Spike flag is bypassed

Because && binds more tightly than ||, flagSpikes only controls the first script-time check. Calling dumpStats with its default flagSpikes = FALSE still emits the slow-script warning whenever slowScript2 exceeds the threshold, producing misleading output when spike warnings were not requested. Group both threshold checks under the flag.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is not working right, typically is user facingZHRelates to Zero Hour

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions