AWStats icon indicating copy to clipboard operation
AWStats copied to clipboard

infinite loop at AddInTree

Open nobod33 opened this issue 1 year ago • 4 comments

Describe the bug

On one particular dataset getting into semi random infinite loops add AddInTree:

        # Val is a new one higher
        if ($Debug) {
                debug( "  keytoadd val=$keyval is higher than lowerval=$lowerval", 4 );
        }
        $val{$keyval} = $keytoadd;
        my $valcursor = $lowerval;    # valcursor is value just before keyval
        while ( $nextval{$valcursor} && ( $nextval{$valcursor} < $keyval ) ) {
                if($valcursor == $nextval{$valcursor}) {
                        print "loop\n";
                }
                $valcursor = $nextval{$valcursor};
        }

It's not constant. Sometimes finishes, more often than not - no. Original host where it was first observed - Cloudlinux 8(Awstats - 7.9 (build 20230108)/perl v5.26.3), for testing purposes copied dataset to Debian 11(Awstats - 7.9 (build 20230108)/perl v5.32.1) machine, where it shows similar/same behaviour. Following ofc. Is not from original code:

                if($valcursor == $nextval{$valcursor}) {
                        print "loop\n";
                }

seen no specific pattern on where it hangs(XXXX.YYY ann some-pathY are changed):

Tue Jan 23 14:13:41 2024 - DEBUG 4 - &nbsp;&nbsp;  Add in tree entry 100 : //XXXX.YYY/some-pathX/ (value=9, tree not full)<br />
Tue Jan 23 14:13:41 2024 - DEBUG 4 - &nbsp;&nbsp;  keytoadd val=9 is higher than lowerval=1<br />
Tue Jan 23 14:14:32 2024 - DEBUG 4 - &nbsp;&nbsp;  Add in tree entry 40 : //XXXX.YYY/some-pathY/ (value=76, tree not full)<br />
Tue Jan 23 14:14:32 2024 - DEBUG 4 - &nbsp;&nbsp;  keytoadd val=76 is higher than lowerval=1<br />

To Reproduce Steps to reproduce the behavior are likely data dependent. Otherwise following has been executed.

/usr/bin/perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=XXXX.YYY -staticlinks=awstats.XXXX.YYY.2401 -diricons=icon -configdir=/home/USERNAME/domains/XXXX.YYY/awstats/.data -output=keywords

nobod33 avatar Jan 23 '24 12:01 nobod33

We've noticed the same issue. I've managed to trigger the behavior with the following few lines

$lowerval = 0;
%val      = ();
%nextval  = ();
%egal     = ();
AddInTree("0", 30, 0);
AddInTree("--", 30);
AddInTree("testing", 237);

manuelm avatar Feb 21 '24 13:02 manuelm

We're facing exactly the same issue with infinitive loop in

while ( $nextval{$valcursor} && ( $nextval{$valcursor} < $keyval ) ) {

Any news on when it could possibly be pached?

akansc avatar Mar 25 '24 08:03 akansc

Any news on when it could possibly be pached?

See https://github.com/eldy/AWStats/pull/247

manuelm avatar Mar 25 '24 08:03 manuelm

Yes, but this was not merged yet. We did apply to the one particular system that currently fails nasty with the bug, but we're reluctant on mass applying the patch without an official release.

akansc avatar Mar 25 '24 09:03 akansc