Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repeated pipe open broken #1007

Closed
p5pRT opened this issue Dec 30, 1999 · 4 comments
Closed

repeated pipe open broken #1007

p5pRT opened this issue Dec 30, 1999 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 30, 1999

Migrated from rt.perl.org#1957 (status was 'resolved')

Searchable as RT1957$

@p5pRT
Copy link
Author

p5pRT commented Dec 30, 1999

From @andk

This bug was introduced between 5.5.57 and 5.5.58

% ./perl5.005_57/perl -e 'print $], "\n";
for (1,2,3){
  open P, "echo foo|" or print "not ";
  print "ok $_\n";
}
'
5.00557
ok 1
ok 2
ok 3
% ./perl5.005_58/perl -e 'print $], "\n";
for (1,2,3){
  open P, "echo foo|" or print "not ";
  print "ok $_\n";
}
'
5.00558
ok 1
not ok 2
not ok 3

Perl Info


This perlbug was built using Perl 5.00503 - Mon Aug 30 23:08:56 EDT 1999
It is being executed now by  Perl 5.00563 - Thu Nov 18 16:20:57 CET 1999.

Site configuration information for perl 5.00563:

Configured by k at Thu Nov 18 16:20:57 CET 1999.

Summary of my perl5 (revision 5.0 version 5 subversion 63) configuration:
  Platform:
    osname=linux, osvers=2.2.12, archname=i586-linux
    uname='linux hohenstaufen.in-berlin.de 2.2.12 #2 smp sat oct 2 11:10:42 cest 1999 i586 unknown '
    config_args='-Dprefix=/sources-perl/inst/perl5.005_62..4590g -Doptimize=-g -des -Dusemymalloc'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
    use64bits=undef usemultiplicity=undef
  Compiler:
    cc='cc', optimize='-g', gccversion=2.7.2.3
    cppflags='-Dbool=char -DHAS_BOOL -DDEBUGGING -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -DDEBUGGING -I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=/lib/libc-2.0.7.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00563:
    /sources-perl/inst/perl5.005_62..4590g/lib/5.00563/i586-linux
    /sources-perl/inst/perl5.005_62..4590g/lib/5.00563
    /sources-perl/inst/perl5.005_62..4590g/lib/site_perl/5.00563/i586-linux
    /sources-perl/inst/perl5.005_62..4590g/lib/site_perl
    .


Environment for perl 5.00563:
    HOME=/home/k
    LANG=en_US
    LANGUAGE (unset)
    LC_ALL=en_US
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/k/bin:/usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin:/usr/bin:/home/k/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/perl/bin
    PERL_BADLANG (unset)
    SHELL=/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Dec 30, 1999

From @gsar

On Thu, 30 Dec 1999 19​:07​:33 +0100, "Andreas J. Koenig" wrote​:

% ./perl5.005_58/perl -e 'print $], "\n";
for (1,2,3){
open P, "echo foo|" or print "not ";
print "ok $_\n";
}
'
5.00558
ok 1
not ok 2
not ok 3

This appears to be due to​:

  [ 3786] By​: gsar on 1999/07/27 06​:30​:09
  Log​: applied suggested patch; added missing prototype changes to
  opcode.pl along with documentation typos (feature still needs
  to be described in perlopentut.pod and summarized in
  perldelta.pod)
  From​: Ilya Zakharevich <ilya@​math.ohio-state.edu>
  Date​: Thu, 17 Jun 1999 00​:39​:34 -0400 (EDT)
  Message-Id​: <199906170439.AAA18154@​monk.mps.ohio-state.edu>
  Subject​: [PATCH 5.00557] 3-arg open
  Branch​: perl
  ! doio.c embed.h embed.pl global.sym objXSUB.h opcode.h
  ! opcode.pl perlapi.c pod/perldiag.pod pod/perlfunc.pod pp_sys.c
  ! proto.h t/comp/proto.t t/io/open.t

Here's one clue​:

  % perl -le '$_ = "echo x|"; open P, $_ or die; print'
  echo x
  ^
Note missing "|" at end.

Sarathy
gsar@​ActiveState.com

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2000

From @gsar

On Thu, 30 Dec 1999 13​:15​:14 PST, I wrote​:

On Thu, 30 Dec 1999 19​:07​:33 +0100, "Andreas J. Koenig" wrote​:

% ./perl5.005_58/perl -e 'print $], "\n";
for (1,2,3){
open P, "echo foo|" or print "not ";
print "ok $_\n";
}
'
5.00558
ok 1
not ok 2
not ok 3

This appears to be due to​:

[ 3786] By​: gsar on 1999/07/27 06​:30​:09
Log​: applied suggested patch; added missing prototype changes to
opcode.pl along with documentation typos (feature still needs
to be described in perlopentut.pod and summarized in
perldelta.pod)
From​: Ilya Zakharevich <ilya@​math.ohio-state.edu>
Date​: Thu, 17 Jun 1999 00​:39​:34 -0400 (EDT)
Message-Id​: <199906170439.AAA18154@​monk.mps.ohio-state.edu>
Subject​: [PATCH 5.00557] 3-arg open
Branch​: perl
! doio.c embed.h embed.pl global.sym objXSUB.h opcode.h
! opcode.pl perlapi.c pod/perldiag.pod pod/perlfunc.pod pp_sys.c
! proto.h t/comp/proto.t t/io/open.t

Here's one clue​:

% perl -le '$_ = "echo x|"; open P, $_ or die; print'
echo x
^
Note missing "|" at end.

This patch is meant to fix that.

Sarathy
gsar@​ActiveState.com

Inline Patch
-----------------------------------8<-----------------------------------
Change 4757 by gsar@auger on 2000/01/05 12:48:10

	severe bugs in change#3786 fixed

Affected files ...

... //depot/perl/doio.c#90 edit
... //depot/perl/t/io/open.t#12 edit

Differences ...

==== //depot/perl/doio.c#90 (text) ====
Index: perl/doio.c
--- perl/doio.c.~1~	Wed Jan  5 04:48:15 2000
+++ perl/doio.c	Wed Jan  5 04:48:15 2000
@@ -183,28 +183,29 @@
 	}
     }
     else {
-	char *myname;
-	char *type = name;
-	char *otype = name;
+	char *type;
+	char *oname = name;
 	STRLEN tlen;
-	STRLEN otlen = len;
+	STRLEN olen = len;
 	char mode[3];		/* stdio file mode ("r\0" or "r+\0") */
 	int dodup;
 
+	type = savepvn(name, len);
+	tlen = len;
+	SAVEFREEPV(type);
 	if (num_svs) {
-	    type = name;
-	    name = SvPV(svs, tlen) ;
-	    len = (I32)tlen;
+	    STRLEN l;
+	    name = SvPV(svs, l) ;
+	    len = (I32)l;
+	    name = savepvn(name, len);
+	    SAVEFREEPV(name);
 	}
-
-	tlen = otlen;
-	myname = savepvn(name, len);
-	SAVEFREEPV(myname);
-	name = myname;
-	if (!num_svs)
+	else {
 	    while (tlen && isSPACE(type[tlen-1]))
 		type[--tlen] = '\0';
-
+	    name = type;
+	    len = tlen;
+	}
 	mode[0] = mode[1] = mode[2] = '\0';
 	IoTYPE(io) = *type;
 	if (*type == '+' && tlen > 1 && type[tlen-1] != '|') { /* scary */
@@ -216,12 +217,14 @@
 	if (*type == '|') {
 	    if (num_svs && (tlen != 2 || type[1] != '-')) {
 	      unknown_desr:
-		Perl_croak(aTHX_ "Unknown open() mode '%.*s'", otlen, otype);
+		Perl_croak(aTHX_ "Unknown open() mode '%.*s'", olen, oname);
 	    }
 	    /*SUPPRESS 530*/
-	    for (type++; isSPACE(*type); type++) ;
-	    if (!num_svs)
+	    for (type++, tlen--; isSPACE(*type); type++, tlen--) ;
+	    if (!num_svs) {
 		name = type;
+		len = tlen;
+	    }
 	    if (*name == '\0') { /* command is missing 19990114 */
 		dTHR;
 		if (ckWARN(WARN_PIPE))
@@ -232,9 +235,9 @@
 	    if (strNE(name,"-") || num_svs)
 		TAINT_ENV();
 	    TAINT_PROPER("piped open");
-	    if (name[strlen(name)-1] == '|') {
+	    if (name[len-1] == '|') {
 		dTHR;
-		name[strlen(name)-1] = '\0' ;
+		name[--len] = '\0' ;
 		if (ckWARN(WARN_PIPE))
 		    Perl_warner(aTHX_ WARN_PIPE, "Can't open bidirectional pipe");
 	    }
@@ -308,7 +311,7 @@
 		    if (!(fp = PerlIO_fdopen(fd,mode))) {
 			if (dodup)
 			    PerlLIO_close(fd);
-			}
+		    }
 		}
 	    }
 	    else {

==== //depot/perl/t/io/open.t#12 (xtext) ====
Index: perl/t/io/open.t
--- perl/t/io/open.t.~1~	Wed Jan  5 04:48:15 2000
+++ perl/t/io/open.t	Wed Jan  5 04:48:15 2000
@@ -5,7 +5,7 @@
 $^W = 1;
 $Is_VMS = $^O eq 'VMS';
 
-print "1..64\n";
+print "1..66\n";
 
 my $test = 1;
 
@@ -258,3 +258,12 @@
 ok;
 $@ =~ /Unknown open\(\) mode \'<&\'/ or print "not ";
 ok;
+
+# 65..66
+{
+    local *F;
+    for (1..2) { open(F, "echo #foo|") or print "not "; }
+    ok;
+    for (1..2) { open(F, "-|", "echo #foo") or print "not "; }
+    ok;
+}
End of Patch.

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2000

From [Unknown Contact. See original ticket]

Gurusamy Sarathy writes​:

Here's one clue​:

% perl -le '$_ = "echo x|"; open P, $_ or die; print'
echo x
^
Note missing "|" at end.

This patch is meant to fix that.

Thanks. Exactly when I sat down to run it through debugger! Good
timing... ;-)

Ilya

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant