Skip Menu |

This queue is for tickets about the Schedule-Cron CPAN distribution.

Report information
The Basics
Id: 69116
Status: open
Priority: 0/
Queue: Schedule-Cron

People
Owner: Nobody in particular
Requestors: develop [...] traveljury.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.01
Fixed in: (no value)



Subject: Schedule::Cron interferes with system calls
Hi Roland I'm afraid I'm seeing a regression with 1.01. In a forked process, I do a system call to 'convert' and half the time these are now failing. I think the reaper is catching the SIGCHLD from the system call incorrectly. I've reverted to 0.99 and all is working again. Let me know what info I can give you to help solve this ta clint
Btw, I'm using IPC::Run to do the system calls clint
From: tlhackque [...] yahoo.com
Sounds like something I noticed code-reading recently. (see 69110). Since you have a reproducer, suggestion: on lines 141 and 166, add $? and ${^CHILD_ERROR_NATIVE} to the local( $!,%!) statements. I suspect this will help (but I run NOFORK, so no promises.) On Tue Jun 28 07:19:24 2011, DRTECH wrote: Show quoted text
> Hi Roland > > I'm afraid I'm seeing a regression with 1.01. In a forked process, I
do Show quoted text
> a system call to 'convert' and half the time these are now failing. > > I think the reaper is catching the SIGCHLD from the system call
incorrectly. Show quoted text
> > I've reverted to 0.99 and all is working again. > > Let me know what info I can give you to help solve this > > ta > > clint
From: tlhackque [...] yahoo.com
Also, if this doesn't solve your problem, the specific error(s) returned from system() would help (Roland) to track this down, as would a small reproducer. But try my suggestion first - it does match the symptoms. On Tue Jun 28 08:31:58 2011, tlhackque wrote: Show quoted text
> Sounds like something I noticed code-reading recently. (see 69110). > > Since you have a reproducer, suggestion: on lines 141 and 166, add
$? Show quoted text
> and ${^CHILD_ERROR_NATIVE} to the local( $!,%!) statements. > > I suspect this will help (but I run NOFORK, so no promises.) >
On Tue Jun 28 08:31:58 2011, tlhackque wrote: Show quoted text
> Sounds like something I noticed code-reading recently. (see 69110). > > Since you have a reproducer, suggestion: on lines 141 and 166, add $? > and ${^CHILD_ERROR_NATIVE} to the local( $!,%!) statements. > > I suspect this will help (but I run NOFORK, so no promises.)
Yes, that seems a reasonable suggestion. I'm trying it out. Actually, I'm wondering if the forking code shouldn't just localise $SIG{CHLD}, as you really don't need that handler in the child process. Could resolve the issue with the specific reaper too. clint
From: tlhackque [...] yahoo.com
In the forking case, there's no need to localize as the fork is just going to evaporate. Doing anyting with the signal is unnecessary. You could try this, adding 1 line between 1217 and 1218: 1208: unless ($cfg->{nofork}) { if ($pid = fork) { # Parent $log->(0,"Schedule::Cron - Forking child PID $pid") if $log && $loglevel <= 0; # Register PID $STARTEDCHILD{$pid} = 1; return; } $SIG{CHLD}='DEFAULT'; } Show quoted text
> Actually, I'm wondering if the forking code shouldn't just localise > $SIG{CHLD}, as you really don't need that handler in the child
process. Show quoted text
> > Could resolve the issue with the specific reaper too. > > clint
On Tue Jun 28 11:41:39 2011, tlhackque wrote: Show quoted text
> In the forking case, there's no need to localize as the fork is just > going to evaporate. Doing anyting with the signal is unnecessary.
Yes - and I think it is this existing SIG{CHLD} handler from the parent which is interfering with system calls in the child. Show quoted text
> $SIG{CHLD}='DEFAULT';
yeah, i should have done this. Instead, i tried with local $SIG{CHLD} in the same position. Even with this change and localizing the two extra vars, I was still getting similar errors, with IPC::Run::run() returning false (which indicates an error, unlike system()) and $? set to -1. Also, my DB connection disappears every now and again, and gives me "can't connect". NO idea what is going on there. That said, I've gone back to 0.99 again and all is running smoothly.
From: tlhackque [...] yahoo.com
local in that place won't work because local's scope ends with the block. So it didn't do anything -- you put it at the end of a block. Assigning to $SIG will last thru the fork exit() at the end of the routine. Also, I'd switch REAPER to use reaper_specific rather than reaper_all. Your child process is still in the parent group and can be caught by the background poller as well as by a signal. The -1 sounds like waitpid overwriting $? when finds no more kids to reap. Did you localize $? in BOTH places? The other possibility is that the parent reaps the kid by mistake; then IPC::Run tries to reap it - but it's gone, so it gets the -1. Since it doesn't expect someone else to have reaped it, the -1 is an error. (Which is reasonable since Cron has prevented IPC from getting the exit status.) I think assigning to $SIG and switching to reaper_specific has a good chance of solving your problem. Roland may have other thoughts. On Tue Jun 28 11:51:25 2011, DRTECH wrote: Show quoted text
> On Tue Jun 28 11:41:39 2011, tlhackque wrote:
> > In the forking case, there's no need to localize as the fork is
just Show quoted text
> > going to evaporate. Doing anyting with the signal is unnecessary.
> > Yes - and I think it is this existing SIG{CHLD} handler from the
parent Show quoted text
> which is interfering with system calls in the child. >
> > $SIG{CHLD}='DEFAULT';
> > yeah, i should have done this. Instead, i tried with local $SIG{CHLD} > in the same position. > > Even with this change and localizing the two extra vars, I was still > getting similar errors, with IPC::Run::run() returning false (which > indicates an error, unlike system()) and $? set to -1. > > Also, my DB connection disappears every now and again, and gives me > "can't connect". NO idea what is going on there. > > That said, I've gone back to 0.99 again and all is running smoothly.