Skip Menu |

This queue is for tickets about the Expect CPAN distribution.

Report information
The Basics
Id: 97319
Status: open
Priority: 0/
Queue: Expect

People
Owner: Nobody in particular
Requestors: felipe [...] felipegasper.com
Cc: ether [...] cpan.org
AdminCc:

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



Subject: eval-fork-die bug in Expect 1.21
Date: Thu, 17 Jul 2014 13:26:36 -0500
To: bug-Expect [...] rt.cpan.org
From: Felipe Gasper <felipe [...] felipegasper.com>
use Expect (); my $pid = $$; open my $stdout, '>&=', STDOUT or die $!; print {$stdout} "PID: ${$}$/"; my ( $expect, $err ); local $@; eval { Expect->spawn('/does/not/exist') }; print {$stdout} "PID after Expect: ${$}$/"; die if $$ != $pid; ===================== The above should print two “PID after Expect” messages. If it doesn’t, run strace on it to verify that the process does NOT end with the die() statement in Expect::spawn. (The SIGHUP to the child--which, where does that come from??--is race-y with the stuff after eval {}.) This is a pretty big problem; since Expect() can die(), it always needs eval {} around it, but that produces a difficult-to-find race condition. -Felipe Gasper cPanel, Inc.
Subject: Re: [rt.cpan.org #97319] AutoReply: eval-fork-die bug in Expect 1.21
Date: Thu, 17 Jul 2014 13:36:45 -0500
To: bug-Expect [...] rt.cpan.org
From: Felipe Gasper <felipe [...] felipegasper.com>
Clarification: Two “PID after Expect” messages only “should” happen to demonstrate the bug. When the bug is fixed, there should only be one.
I ran this on OSX with perl 5.20.0 using Expect 1.21 and this is the output I got. PID: 71083 PID after Expect: 71083 Could you please provide more details about your environment?
Subject: Re: [rt.cpan.org #97319] eval-fork-die bug in Expect 1.21
Date: Sun, 03 Aug 2014 15:24:21 -0500
To: bug-Expect [...] rt.cpan.org
From: Felipe Gasper <felipe [...] felipegasper.com>
On 3 Aug 2014 3:19 PM, Gabor Szabo via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=97319 > > > > > I ran this on OSX with perl 5.20.0 using Expect 1.21 and this is the output I got. > > PID: 71083 > PID after Expect: 71083 > > Could you please provide more details about your environment? >
I was using perl 5.14 on Linux. The bug appears to be race-y; the below is from perl 5.12 on OS X Mavericks with Expect.pm 1.21: ============== felipe@Macintosh-19 15:21:51 ~ Show quoted text
> pbpaste | perl
PID: 61559 PID after Expect: 61559 OK felipe@Macintosh-19 15:22:18 ~ Show quoted text
> pbpaste | perl
PID: 61570 PID after Expect: 61570 OK felipe@Macintosh-19 15:22:20 ~ Show quoted text
> pbpaste | perl
PID: 61581 PID after Expect: 61582 PID after Expect: 61581 OK felipe@Macintosh-19 15:22:21 ~ Show quoted text
> pbpaste | perl
PID: 61592 PID after Expect: 61593 PID after Expect: 61592 ============== -FG
This was noticed with the new Test::Builder alphas. This issue is pretty significant. When the exec after fork fails it should not use die, it should ensure the exit happens by emulating a die right there. warn "Failed to exec"; exit 255; This will ensure the process actually exits (you spawn the process, it is your job to make sure it exits) Without this any eval before the spawn can capture the error resulting in 2 processes running, which I am 99% sure is never what you want. Currently this test suite fails with the Test::Builder alphas. There are 2 problems, the first is that Test::Builder is somehow swallowing the exception, which is wrong. The other is the fact that this should be a die, not an exception. Here is the Test-More ticket: https://github.com/Test-More/test-more/issues/499