Bug in void ShapeBase::updateImageState(U32 imageSlot,F32 dt)
by Vince Gee · in Torque 3D Professional · 07/18/2012 (5:12 pm) · 6 replies
Ok, I have no clue what is causing the bug, but I can reproduce it.
The code in this function uses "goto" statements, uck....
Well there is a loop in there where I assume it is checking to make sure the delays are done and such.
The problem, I think is my trigger sometimes get stuck (i.e. the mouse down) or something like that... and that condition is always met. So the loop continues and continues and continues.
I have about 75 AI running around using rocket launchers, machine guns and land mines, so the battlefield is pretty heavy. And I usually die pretty quick. I'm not sure if this routine is getting stuck because I am dead or what.
I traced it down by following the assembly language when the game appeared to hang. So what ever the reason, it can occur.
To fix it, I put
around line 2970
and I put
Around line 3082
And magically, I now got console messages instead of crashes telling me the loop max was hit. This error did not occur until the client was under heavy load, i.e. 100%cpu utilitization. It did go away when I slowed the tick down(sgTimeManagerProcessInterval) as well. So I'm guessing this is something load related.
If someone can shed some like on what that loop max count should be like, I'd appreciate it, but to be honest, I've been hunting this bug for about a month now... I'm just glad that I have a fix.
Vince
The code in this function uses "goto" statements, uck....
Well there is a loop in there where I assume it is checking to make sure the delays are done and such.
if ( image.rDT > 0.0f && image.delayTime > 0.0f && imageData.useRemainderDT && dt != 0.0f )
goto TICKAGAIN;The problem, I think is my trigger sometimes get stuck (i.e. the mouse down) or something like that... and that condition is always met. So the loop continues and continues and continues.
I have about 75 AI running around using rocket launchers, machine guns and land mines, so the battlefield is pretty heavy. And I usually die pretty quick. I'm not sure if this routine is getting stuck because I am dead or what.
I traced it down by following the assembly language when the game appeared to hang. So what ever the reason, it can occur.
To fix it, I put
image.rDT = dt; F32 elapsed; S32 loopcounter=0; TICKAGAIN: loopcounter++; if (loopcounter>100) goto FATT; ShapeBaseImageData::StateData& stateData = *image.state;
around line 2970
and I put
if ( image.rDT > 0.0f && image.delayTime > 0.0f && imageData.useRemainderDT && dt != 0.0f )
goto TICKAGAIN;
goto FEND;
FATT:
Con::errorf("Loop Max hit... exiting rough.");
FEND:
loopcounter=0;Around line 3082
And magically, I now got console messages instead of crashes telling me the loop max was hit. This error did not occur until the client was under heavy load, i.e. 100%cpu utilitization. It did go away when I slowed the tick down(sgTimeManagerProcessInterval) as well. So I'm guessing this is something load related.
If someone can shed some like on what that loop max count should be like, I'd appreciate it, but to be honest, I've been hunting this bug for about a month now... I'm just glad that I have a fix.
Vince
About the author
www.winterleafentertainment.com
#2
this line here image.delayTime -= dt
this is my work around for now....... until Im able to pin point or fix the problem
07/19/2012 (8:18 am)
Ive been dealing with this bug to, tho i cant really pin point it. From what i can figure, for some reason dt becomes a very very small number, and it takes forever for it to subtract from image.delaytime, witch is causing hangs ups or even lockups. this line here image.delayTime -= dt
this is my work around for now....... until Im able to pin point or fix the problem
image.rDT = dt;
F32 elapsed;
TICKAGAIN:
ShapeBaseImageData::StateData& stateData = *image.state;
//////////////////////////////////////////added if statement
if( dt < 0.001){//dt Failsafe
dt = 0.001;
}
////////////////////////////////////////
if ( image.delayTime > dt )
elapsed = dt;
#3
07/19/2012 (8:41 am)
Probally because the player is dead. I noticed that this error usually happened when I was using the rocket launcher and a AI killed me while I was shooting.
#4
'goto' is not inherently bad. They are bad when used to replace constructs that would better solve the problem. In the case of the VM they are used when it is not desired to increment the instruction pointer, and when exiting the currently evaluated code block. They help avoid comparisons that would slow down the operation of the VM.
07/19/2012 (10:50 am)
Also, why are we using gotos? This is 2012 ;P.Don't look at the TS VM if you don't like goto statements...
'goto' is not inherently bad. They are bad when used to replace constructs that would better solve the problem. In the case of the VM they are used when it is not desired to increment the instruction pointer, and when exiting the currently evaluated code block. They help avoid comparisons that would slow down the operation of the VM.
#5
07/19/2012 (11:13 am)
So this goto is a performance thing... well... we still need an emergency out... or something, cause this crash cost me a month of ripping my dotnettorque a apart thinking that it was something I was doing wrong in the csharp implementation.
#6
07/20/2012 (1:53 am)
Frank: oh, I agree; I actually quite like gotos. I was just being a bit cheeky because I know gotos are no longer idiomatic since we have more advanced constructs to do the same job, and better compilers to optimise our code!
Torque Owner Daniel Buckmaster
T3D Steering Committee
Also, why are we using gotos? This is 2012 ;P.