Subject: | Infinite loop when unexpected cron string comes in |
Hi,
I've put Algorithm::Cron to use quite nicely generating
System::Introspector reports of the cron invocations that will happen
for the current week across an entire set of servers. A::C works
fantastically well except when it gets unexpected input there's a case
where it'll go into an infinite loop. One of those cases is Vixie cron
special values such as @daily or @reboot. Some sample code and the
output are below.
Making warnings fatal is a fairly trivial way to at least stop the
infinite loop which I as the caller of next_time() don't seem to be able
to break out of. Then an end user could just wrap the invocations with
eval and gracefully handle the cases where one cron line has something
Algorithm:Cron can't deal with but not the others.
Cheers and thanks for those module!
Tyler Riddle
use strictures;
use Algorithm::Cron;
#also @reboot causes this issue
my $cron = Algorithm::Cron->new(crontab => '@daily', base => 'utc');
my $time = time();
while(1) {
$time = $cron->next_time($time);
warn $time;
}
Causes infinite loop while perl generates warnings:
Use of uninitialized value $spec in string eq at lib//Algorithm/Cron.pm
line 156.
Use of uninitialized value $spec in split at lib//Algorithm/Cron.pm line
159.
Use of uninitialized value $spec in string eq at lib//Algorithm/Cron.pm
line 156.
Use of uninitialized value $spec in split at lib//Algorithm/Cron.pm line
159.
Use of uninitialized value $spec in string eq at lib//Algorithm/Cron.pm
line 156.
Use of uninitialized value $spec in split at lib//Algorithm/Cron.pm line
159.
Use of uninitialized value $spec in string eq at lib//Algorithm/Cron.pm
line 156.
Use of uninitialized value $spec in split at lib//Algorithm/Cron.pm line
159.
Use of uninitialized value in subroutine entry at lib//Algorithm/Cron.pm
line 197.
Use of uninitialized value in subroutine entry at lib//Algorithm/Cron.pm
line 197.
Use of uninitialized value in subroutine entry at lib//Algorithm/Cron.pm
line 197.
Use of uninitialized value in subroutine entry at lib//Algorithm/Cron.pm
line 197.
Use of uninitialized value in subroutine entry at lib//Algorithm/Cron.pm
line 197.
Use of uninitialized value in subroutine entry at lib//Algorithm/Cron.pm
line 197.
Use of uninitialized value in subroutine entry at lib//Algorithm/Cron.pm
line 197.