Division by zero in innreport
John F. Morse
inn at xanadu-bbs.net
Thu Jan 5 02:25:13 UTC 2012
Julien ÉLIE wrote:
> Hi John,
>
>> Errors started on January 1. First change of the year.
>>
>> Illegal division by zero at /usr/lib/news/bin/innreport line 1747.
>> Daily Usenet report for my.net from Jan 3 00:00:02 to Jan 4 00:00:01
>>
>>
>> 1743 foreach $key (sort keys %$dates) {
>> 1744 $x_min = $key if $x_min > $key;
>> 1745 $x_max = $$dates{$key} if $x_max < $$dates{$key};
>> 1746 my $delta = $dates->{$key} - $key;
>> 1747 my $t = $out->{$key} / $delta;
>> 1748 $y_max_out = $t if $y_max_out < $t;
>> 1749 $t = $in->{$key} / $delta;
>> 1750 $y_max_in = $t if $y_max_in < $t;
>> 1751 }
>
> Thanks for the bug report.
>
> The problem comes from the parsing of innreport.db (for HTML pages generated
> by innreport).
>
> If you have in this file a change of year for which the hours are the same
> between Dec 31th and Jan 1st, then this error is generated.
>
> For instance:
>
> news-notice.2010.12.31-04.15.02.html|Dec 31 04:15:02 -- Jan 1 04:15:02|28079|2791|7.9 MB|34320|1500|4.6 MB
>
> There is an issue in how innreport translates these dates. The ConvDate()
> function assumes the dates are relative to the *current* year. So it
> thinks it has been passed Dec 31th 2012 and Jan 1st 2012 (whereas it was
> Dec 31th 2010 and Jan 1st 2011). As 2012 is a leap year, and Dec 31th
> is after Feb 28th, the translated date contains an unexpected "+1 day".
>
> In innreport we have:
>
> $start = &ConvDate ($start);
> $end = &ConvDate ($end);
> # 31/12 - 1/1 ?
> my $inc = $end < $start ? 1 : 0;
> $start += (($year - 1970) * 365 +
> int (($year - 1968) / 4)) * 3600 * 24;
> $year += $inc;
> $end += (($year + - 1970) * 365 + int (($year - 1968) / 4)) * 3600 * 24;
> $dates{$start} = $end;
>
> Which is exactly the variables used by the code you quoted above:
> my $delta = $dates->{$key} - $key;
> $delta equals 0 here, whence the illegal division.
>
>
>
> The visible effect of this bug is for instance:
> http://common.albasani.net/innreport/
> where the main page has not been updated since the beginning of the year.
> It is caused by the presence of "Dec 31 04:15:02 -- Jan 1 04:15:02".
>
> No HTML report is lost. They are properly generated, but the main page
> is not updated. For instance, Jan 3rd is here:
> http://common.albasani.net/innreport/news-notice.2012.01.01-03.15.31.xhtml
>
>
>
> Thanks again for having caught that issue.
> It is a bit annoying for those who generate HTML reports.
Yes it is.
Earlier I didn't notice the main page was "frozen" like albasani's is, but I
see the same things here, and can find the good reports.
Is there anything you could suggest to change to get it restarted? Something
like a quick text edit of a date and/or time in /var/www perhaps?
And thanks for the great Barcelona pictures. ;-)
--
John
More information about the inn-workers
mailing list