Subject: | Working around a Perl bug |
Hiya
I've reported this before, but you closed it because it is a Perl bug.
I'm hoping that you can add a workaround though, as it is causing my
daemon to die regularly.
The daemon dies with: panic: attempt to copy value 1 to a freed scalar
35befe0 at
/opt/perl-5.8.9-unthreaded/lib/site_perl/5.8.9/Schedule/Cron.pm line 1064.
That's the line where it tries to set $STARTEDCHILD{$pid} = 1. From what
I've read, the problem is in the &REAPER, where it does: delete
$STARTEDCHILD{$pid}
A workaround is suggested in
http://www.perlmonks.org/index.pl?node_id=813655 which is to set
$STARTEDCHILD{$pid} = 0, instead of deleting it:
diff -ruN Schedule-Cron-0.99_original/lib/Schedule/Cron.pm
Schedule-Cron-0.99_patched/lib/Schedule/Cron.pm
--- Schedule-Cron-0.99_original/lib/Schedule/Cron.pm 2009-09-12
09:19:15.000000000 +0200
+++ Schedule-Cron-0.99_patched/lib/Schedule/Cron.pm 2010-03-20
16:26:02.000000000 +0100
@@ -130,7 +130,7 @@
my $res = $HAS_POSIX ? waitpid($pid, WNOHANG) :
waitpid($pid,0);
if ($res > 0) {
# We reaped a truly running process
- delete $STARTEDCHILD{$pid};
+ $STARTEDCHILD{$pid} = 0;
}
}
}
@@ -772,6 +772,9 @@
}
$self->_execute($index,$cfg);
+ for (keys %STARTEDCHILD) {
+ delete $STARTEDCHILD{$_} unless $STARTEDCHILD{$_}
+ }
if ($self->{entries_changed}) {
dbg "rebuilding queue";
I don't know whether this will work or not, but I'm testing it in live
as we speak. I see from another bug that you are planning a 1.0 release
soon, so please let me feed back to you on whether this fix works or not
before you do release it.
My daemon dies once every two days or more, so this should show up
pretty quickly
thanks
Clint