Skip Menu | You are currently an anonymous guest. | Login | Return to Main | Preferences
Id: 30952
Status: resolved
Left: 0 min
Priority: 0/0
Queue: perl5

Owner: Nobody
Requestors: petdance <andy [at] petdance.com>
stmpeters <steve [at] fisharerojo.org>
Cc:
AdminCc:

Operating System: cygwin_nt
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version:
  • 5.8.2
  • 5.8.5
Fixed In: (no value)



X History Display mode: Brief headersFull headers
#   Wed Aug 04 20:26:33 2004 stmpeters - Ticket created  
Subject: qx() problems with local environment variables on Cygwin/Perl 5.8.2
Date: Wed, 4 Aug 2004 22:29:26 +0000
To: perlbug@perl.org
From: Steve Peters <steve@fisharerojo.org>
Download (untitled) [text/plain 1.8k]
This problem originally occured while running tests for installing
Test::Harness, but I've been able to replicate it independently. For
reference, the original ticket is available at
http://rt.cpan.org/NoAuth/Bug.html?id=6452.

The problem is that an local environment variable set in an anonymous block
seems to be available to child processes created afterwards using qx(). I
have not tested this using system() or fork(). See the example scripts
below.

test1.pl

#!/usr/bin/perl -w

use warnings;
use strict;

my $key = "WANGO";

BLOCK1: {
my $val = $ENV{$key};
$val = "undef" unless defined $val;
print "In BLOCK1, \$ENV{$key} = [$val]\n";
}


BLOCK2: {
local $ENV{$key} = "FOTANGO";

my $val = $ENV{$key};
$val = "undef" unless defined $val;
print "In BLOCK2, \$ENV{$key} = [$val]\n";
}


BLOCK3: {
my $val = qx/test2.pl/;
$val = "undef" unless defined $val;
print "In BLOCK3, \$ENV{$key} = [$val]\n";
print " ... BUT IT SHOULD BE undef!" unless $val eq "undef";
}

=cut

test2.pl

#!/usr/bin/perl -w

use strict;
my $val = $ENV{WANGO};
$val = "undef" if ! defined $val;
print $val;

=cut

My results on Cygwin are...

In BLOCK1, $ENV{WANGO} = [undef]
In BLOCK2, $ENV{WANGO} = [FOTANGO]
In BLOCK3, $ENV{WANGO} = [FOTANGO]
... BUT IT SHOULD BE undef!


On Linux (Perl 5.8.4 on Gentoo with a 2.4.26 kernel), Win32 (ActiveState Build
810), HP-UX (Perl 5.8.0), and Mac OS X (Perl 5.8.0), the results are...
In BLOCK1, $ENV{WANGO} = [undef]
In BLOCK2, $ENV{WANGO} = [FOTANGO]
In BLOCK3, $ENV{WANGO} = [undef]

Adding an "$ENV{WANGO} = undef;" to the end of BLOCK2 seems to take care of
the problem, but coding this way for just one platform doesn't seem quite
right to me. I'm also not sure if this is actually a problem with Perl or an
issue with Cygwin itself.

Regards,

Steve Peters
steve@fisharerojo.org
#   Wed Aug 04 20:26:36 2004 RT_System - Severity low added  
#   Wed Aug 04 20:26:36 2004 RT_System - Type unknown added  
#   Thu Aug 05 18:30:04 2004 petdance - Requestor petdance added  
#   Thu Aug 05 18:30:56 2004 petdance - Operating System cygwin added  
#   Thu Aug 05 18:31:36 2004 petdance - Comments added  
Download (untitled) [text/plain 74b]
This problem is causing problems with t/prove-switches.t in Test::Harness.
#   Fri Aug 06 23:45:11 2004 fluffy@sixears.co.uk - Correspondence added  
Subject: Re: [perl #30952] qx() problems with local environment variables on Cygwin/Perl 5.8.2
Date: Sat, 7 Aug 2004 06:45:14 +0000
To: perl5-porters@perl.org
From: "Martyn J. Pearce" <fluffy@sixears.co.uk>
Download (untitled) [text/plain 650b]
On Thu, Aug 05, 2004 at 03:26:34AM -0000, Steve Peters wrote:
> The problem is that an local environment variable set in an anonymous block
> seems to be available to child processes created afterwards using qx(). I
> have not tested this using system() or fork(). See the example scripts
> below.

I tried the supplied scripts, but didn't get the results you describe.
I get:
[martyn:0]$ PATH=$PATH:/tmp /tmp/test1.pl
In BLOCK1, $ENV{WANGO} = [undef]
In BLOCK2, $ENV{WANGO} = [FOTANGO]
In BLOCK3, $ENV{WANGO} = [undef]

Please retry them in a separate session; I have to imagine that you have
"WANGO" set in your environment, or similar.

Mx.
#   Fri Aug 06 23:45:13 2004 RT_System - Status changed from 'new' to 'open'  
#   Mon Aug 09 06:27:42 2004 stmpeters - Correspondence added  
CC: andy@petdance.com
Subject: Re: [perl #30952] qx() problems with local environment variables on Cygwin/Perl 5.8.2
Date: Mon, 9 Aug 2004 08:27:40 +0000
To: perlbug-followup@perl.org
From: Steve Peters <steve@fisharerojo.org>
Download (untitled) [text/plain 672b]
> I tried the supplied scripts, but didn't get the results you describe.
> I get:
> [martyn:0]$ PATH=$PATH:/tmp /tmp/test1.pl
> In BLOCK1, $ENV{WANGO} = [undef]
> In BLOCK2, $ENV{WANGO} = [FOTANGO]
> In BLOCK3, $ENV{WANGO} = [undef]
>
> Please retry them in a separate session; I have to imagine that you have
> "WANGO" set in your environment, or similar.

As far as I know, I don't have an environment variable called "WANGO" in my
environment. My guess is that this may be related to the Windows version I
have. The machine that this failed on has NT 4.0 installed. Let me try it
on my XP box and see if I get the same error.

Steve Peters
steve@fisharerojo.org
#   Mon Aug 09 07:42:22 2004 stmpeters - Correspondence added  
CC: perlbug-followup@perl.org, andy@petdance.com
Subject: Re: [perl #30952] qx() problems with local environment variables on Cygwin/Perl 5.8.2
Date: Mon, 9 Aug 2004 09:42:15 +0000
To: perl5-porters@perl.org
From: Steve Peters <steve@fisharerojo.org>
Download (untitled) [text/plain 474b]

> As far as I know, I don't have an environment variable called "WANGO" in my
> environment. My guess is that this may be related to the Windows version I
> have. The machine that this failed on has NT 4.0 installed. Let me try it
> on my XP box and see if I get the same error.
>
OK, I tried it on my Windows XP box and it worked just fine. It must be the
combination of Windows NT 4.0 and Cygwin that's causing these problems.

Steve Peters
steve@fisharerojo.org
#   Tue Sep 14 06:38:55 2004 stmpeters - Operating System cygwin_nt added  
#   Tue Sep 14 06:38:55 2004 stmpeters - Operating System cygwin deleted  
#   Tue Sep 14 06:38:56 2004 stmpeters - Fixed In 5.8.2 added  
#   Tue Sep 14 06:38:56 2004 stmpeters - Fixed In 5.8.5 added  
#   Tue Sep 14 06:39:37 2004 stmpeters - Perl Version 5.8.2 added  
#   Tue Sep 14 06:39:37 2004 stmpeters - Perl Version 5.8.5 added  
#   Tue Sep 14 06:39:37 2004 stmpeters - Fixed In 5.8.2 deleted  
#   Tue Sep 14 06:39:37 2004 stmpeters - Fixed In 5.8.5 deleted  
#   Wed Sep 28 23:42:02 2005 guest - Correspondence added  
Download (untitled) [text/plain 339b]
Bug still present on perl 5.8.7 cygwin-thread-multi-64int / nt4

$ perl test.pl
In BLOCK1, $ENV{WANGO} = [undef]
In BLOCK2, $ENV{WANGO} = [FOTANGO]
In BLOCK3, $ENV{WANGO} = [FOTANGO]
... BUT IT SHOULD BE undef!
$ uname -a
CYGWIN_NT-5.0 reini 1.5.19s(0.137/4/2) 20050814 16:02:26 i686 unknown
unknown Cygwin

I'll report at the cygwin list
#   Tue Oct 11 10:18:35 2005 stmpeters - Correspondence added  
RT-Send-CC: perl5-porters@perl.org
Download (untitled) [text/plain 903b]
> [guest - Wed Sep 28 23:42:02 2005]:
>
> Bug still present on perl 5.8.7 cygwin-thread-multi-64int / nt4
>
> $ perl test.pl
> In BLOCK1, $ENV{WANGO} = [undef]
> In BLOCK2, $ENV{WANGO} = [FOTANGO]
> In BLOCK3, $ENV{WANGO} = [FOTANGO]
> ... BUT IT SHOULD BE undef!
> $ uname -a
> CYGWIN_NT-5.0 reini 1.5.19s(0.137/4/2) 20050814 16:02:26 i686 unknown
> unknown Cygwin
>
> I'll report at the cygwin list
>

The problem was with Perl's handling of environment variables when Perl
is compiled with -DPERL_USE_SAFE_PUTENV. This has been fixed with
change #25737.

steve@redshirt ~/perl-current
$ perl5.8.7.exe test1.pl
In BLOCK1, $ENV{WANGO} = [undef]
In BLOCK2, $ENV{WANGO} = [FOTANGO]
In BLOCK3, $ENV{WANGO} = [FOTANGO]
... BUT IT SHOULD BE undef!
steve@redshirt ~/perl-current
$ ./perl test1.pl
In BLOCK1, $ENV{WANGO} = [undef]
In BLOCK2, $ENV{WANGO} = [FOTANGO]
In BLOCK3, $ENV{WANGO} = [undef]
#   Tue Oct 11 10:18:37 2005 stmpeters - Status changed from 'open' to 'resolved'  


For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org