Menu

#28 Infinite loop + error message in logs

open
nobody
None
8
2008-12-22
2008-12-22
No

Hello!

Recently we had a serious problem with pChart. We use this fine tool for displaying data coming out of a database. With certain parameters it could happen that there is no data to be displayed (e.g. sales from an affiliate who had sold nothing in the last days). So there is no real data to display.

When this happens pChart goes into an infinite loop! The while loop in line 464 (and similar loops below) is never fullfilled! And on top of this $Factor is divided in every loop, getting smaller and smaller until php puts out a "division by zero" error message (and the while loop is still running and running...).

On top of this we have a configuration so that every php error will be written into a log file for later debugging. And I guess you get the picture when every x millisecond a php error message is written into a logfile... In the end we had to delete a 75 GB logfile!

I hope that you fix this soon! I made a small fix myself for the time being but you should have a look at this.

Greetings
Carsten

Discussion

  • Carsten Henkelmann

    • priority: 5 --> 8
     
  • Nobody/Anonymous

    Indeed, the drawScale function can get stuck in an infinite loop during the "while(!$ScaleOk)" code on line 464 of pChart.class. In my case, the data sent was all 0, with a setFixedScale(0,0) used. In such case, I had (back in pChart.class):

    $this->VMin = 0;
    $this->VMax = 0;
    $MaxDivs = 3.6;

    So when the loop starts, none of the conditions are satisfied, because $Scale1 = 1, $Scale = 0.5 and $Scale4 = 0.25. So factor becomes 0.1, loop starts again.

    This time, $Scale1 = 10, $Scale = 5 and $Scale4 = 2.5. Both $Scale1 and $Scale2 are greater than $MaxDivs, so still no go, and factor is converted back to 1.

    Loop goes on like this, toglling between the 2 cases until it times out.

     

Log in to post a comment.

MongoDB Logo MongoDB