Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

[perl #21780] odd bug with handle dup

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


perlbug-followup at perl

Mar 31, 2003, 7:43 PM

Post #1 of 3 (56 views)
Permalink
[perl #21780] odd bug with handle dup

# New Ticket Created by belg4mit [at] mit
# Please include the string: [perl #21780]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=21780 >


This is a bug report for perl from belg4mit [at] mit,
generated with the help of perlbug 1.34 running under perl v5.8.0.


-----------------------------------------------------------------
While playing with code to dup DATA to STDIN I inadvertently came
up with the following

$a = tell(DATA);
seek(DATA,$a,0);
open(STDIN, "<&DATA");
while(<STDIN>){
print "STDIN: $_";
}
__DATA__
Foo
Bar
Quux

The first two lines would seem to be no-ops. And yet in several
instances nothing is read without them. Known configs where this
has failed are this box with the version of perl below as well
as the following perl -V I have also received reports of failure
without the first two lines on builds of 5.8 for SCO and RH

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=solaris, osvers=2.8, archname=sun4-solaris
uname='sunos downy.mit.edu 5.8 generic_108528-12 sun4u sparc sunw,ultraax-i2 '
config_args='-d -s -e -Dprefix=/usr/athena -Dcc=gcc -Dlocincpth=/usr/athena/include -Dloclibpth=/usr/athena/lib -Dperladmin=bugs [at] mit'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
Compiler:
cc='gcc', ccflags ='-fno-strict-aliasing -I/usr/athena/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O',
cppflags='-fno-strict-aliasing -I/usr/athena/include'
ccversion='', gccversion='3.0.3', gccosandvers='solaris2.8'
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, usemymalloc=y, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/athena/lib '
libpth=/usr/athena/lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc -lbsd -liconv
perllibs=-lsocket -lnsl -ldl -lm -lc -lbsd -liconv
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-E'
cccdlflags='-fPIC', lddlflags=' -W,l-E -G -L/usr/athena/lib'


Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under solaris
Compiled at Sep 12 2002 16:20:01
@INC:
/usr/athena/lib/perl5/5.6.1/sun4-solaris
/usr/athena/lib/perl5/5.6.1
/usr/athena/lib/perl5/site_perl/5.6.1/sun4-solaris
/usr/athena/lib/perl5/site_perl/5.6.1
/usr/athena/lib/perl5/site_perl
.
Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
Platform:
osname=solaris, osvers=2.5.1, archname=sun4-solaris
uname='sunos technomage 5.5.1 generic_103640-12 sun4m sparc sunw,sparcclassic '
hint=recommended, useposix=true, d_sigaction=define
bincompat3=y useperlio=undef d_sfio=undef
Compiler:
cc='/usr/gcc/bin/gcc', optimize='-O2', gccversion=2.7.2.1
cppflags=''
ccflags =''
stdchar='unsigned char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=8, usemymalloc=y, prototype=define
Linker and Libraries:
ld='/usr/gcc/bin/gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
libc=/lib/libc.so, so=so
useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fpic', lddlflags='-G -L/usr/local/lib'


Characteristics of this binary (from libperl):
Built under solaris
Compiled at Feb 9 1998 20:13:09
@INC:
/afs/athena/contrib/perl5/arch/sun4x_55/lib/perl5.004
/afs/athena/contrib/perl5/arch/share/perl5.004
/afs/athena/contrib/perl5/arch/sun4x_55/lib/perl5.004/site_perl
/afs/athena/contrib/perl5/arch/share/perl5.004/site_perl
.


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=low
---
Site configuration information for perl v5.8.0:

Configured by belg4mit at Fri Aug 9 06:33:44 EDT 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=solaris, osvers=2.8, archname=sun4-solaris-64int
uname='sunos biohazard-cafe.mit.edu 5.8 generic_108528-12 sun4u sparc sunw,sun-fire-280r '
config_args='-Dprefix=/mit/belg4mit'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=undef usesocks=undef
use64bitint=define use64bitall=undef uselongdouble=undef
usemymalloc=y, bincompat5005=undef
Compiler:
cc='cc', ccflags ='',
optimize='-O',
cppflags=''
ccversion='Sun WorkShop 6 update 1 C 5.2 2000/09/11', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=87654321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4
alignbytes=8, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib -L/mit/sunsoft_v6.1a/SUNWspro/WS6U1/lib'
libpth=/usr/local/lib /mit/sunsoft_v6.1a/SUNWspro/WS6U1/lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -ldl -lm -lc
perllibs=-lsocket -lnsl -ldl -lm -lc
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-KPIC', lddlflags='-G -L/usr/local/lib -L/mit/sunsoft_v6.1a/SUNWspro/WS6U1/lib'

Locally applied patches:


---
@INC for perl v5.8.0:
/mit/belg4mit/lib/perl5/5.8.0/sun4-solaris-64int
/mit/belg4mit/lib/perl5/5.8.0
/mit/belg4mit/lib/perl5/site_perl/5.8.0/sun4-solaris-64int
/mit/belg4mit/lib/perl5/site_perl/5.8.0
/mit/belg4mit/lib/perl5/site_perl
.

---
Environment for perl v5.8.0:
HOME=/mit/belg4mit
LANG (unset)
LANGUAGE (unset)
LD_LIBRARY_PATH=/usr/openwin/lib
LOGDIR (unset)
PATH=/mit/belg4mit/Private:/mit/belg4mit/arch/sun4x_58/bin:/srvd/patch:/usr/athena/bin:/usr/athena/etc:/bin/athena:/usr/openwin/bin:/usr/openwin/demo:/usr/bin:/usr/ccs/bin:/usr/sbin:/sbin:/usr/ucb:/mit/sipb/arch/sun4x_58/bin:/mit/gnu/arch/sun4x_58/bin:/mit/games/arch/sun4x_58/bin:/mit/consult/arch/sun4x_58/bin:/mit/outland/arch/sun4x_58/bin:/mit/perl5/arch/sun4x_58/bin:/mit/perl/arch/sun4x_58/bin
PERL_BADLANG (unset)
SHELL=/bin/athena/tcsh


uri at stemsystems

Apr 21, 2012, 10:03 AM

Post #2 of 3 (51 views)
Permalink
Re: [perl #21780] odd bug with handle dup [In reply to]

On 04/21/2012 12:02 PM, James E Keenan via RT wrote:
> On Mon Mar 31 18:43:53 2003, belg4mit [at] mit wrote:
>> This is a bug report for perl from belg4mit [at] mit,
>> generated with the help of perlbug 1.34 running under perl v5.8.0.
>>
>>
>> -----------------------------------------------------------------
>> While playing with code to dup DATA to STDIN I inadvertently came
>> up with the following
>>
>> $a = tell(DATA);
>> seek(DATA,$a,0);
>> open(STDIN, "<&DATA");
>> while(<STDIN>){
>> print "STDIN: $_";
>> }
>> __DATA__
>> Foo
>> Bar
>> Quux
>>
>> The first two lines would seem to be no-ops. And yet in several
>> instances nothing is read without them. Known configs where this
>> has failed are this box with the version of perl below as well
>> as the following perl -V [all Solaris.] I have also received reports
> of failure
>> without the first two lines on builds of 5.8 for SCO and RH
>>
>
> On Sat May 10 10:32:12 2003, ni-s wrote:
>> Strange how these things go unnoticed for ages then get discovered
>> by several people at nearly same time.
>> This is caused by "fact" that DATA handle has been read in order to
>> read the script. So some data is in the buffer. The "dup" process
>> does not copy the buffer.
>>
>> Not clear if/how this should be fixed:
>> A. Document it
>> B. Make dup do seek(FH,tell(FH),0) - but with more error checking.
>> C. Make DATA file handle do the seek/tell thing implicitly.
>
> ni-s is no longer with us to handle this old ticket.
>
> This problem appears to be OS-specific; I could not reproduce it on
> Darwin or Debian Linux. Is there someone -- especially on Solaris --
> who can try to reproduce this bug? How should we approach this?

just fyi, i ran into this problem without the dup call. in File::Slurp
slurping the DATA handle which uses sysread has seek issues. my
workaround was to detect it was DATA and to to a sysseek/tell on the
handle before reading it with sysread. so it sounds like the same issue.
i recall it was solaris that had this problem but i can't check it as i
don't have solaris around anymore. so having dup do the seek isn't going
to fix the problem as it shows up without dup.

uri


fraserbn at gmail

Apr 26, 2012, 4:26 PM

Post #3 of 3 (42 views)
Permalink
Re: [perl #21780] odd bug with handle dup [In reply to]

On Sat, Apr 21, 2012 at 1:02 PM, James E Keenan via RT <
perlbug-followup [at] perl> wrote:

> On Mon Mar 31 18:43:53 2003, belg4mit [at] mit wrote:
> > This is a bug report for perl from belg4mit [at] mit,
> > generated with the help of perlbug 1.34 running under perl v5.8.0.
> >
> >
> > -----------------------------------------------------------------
> > While playing with code to dup DATA to STDIN I inadvertently came
> > up with the following
> >
> > $a = tell(DATA);
> > seek(DATA,$a,0);
> > open(STDIN, "<&DATA");
> > while(<STDIN>){
> > print "STDIN: $_";
> > }
> > __DATA__
> > Foo
> > Bar
> > Quux
> >
> > The first two lines would seem to be no-ops. And yet in several
> > instances nothing is read without them. Known configs where this
> > has failed are this box with the version of perl below as well
> > as the following perl -V [all Solaris.] I have also received reports
> of failure
> > without the first two lines on builds of 5.8 for SCO and RH
> >
>
> On Sat May 10 10:32:12 2003, ni-s wrote:
> > Strange how these things go unnoticed for ages then get discovered
> > by several people at nearly same time.
> > This is caused by "fact" that DATA handle has been read in order to
> > read the script. So some data is in the buffer. The "dup" process
> > does not copy the buffer.
> >
> > Not clear if/how this should be fixed:
> > A. Document it
> > B. Make dup do seek(FH,tell(FH),0) - but with more error checking.
> > C. Make DATA file handle do the seek/tell thing implicitly.
>
> ni-s is no longer with us to handle this old ticket.
>
> This problem appears to be OS-specific; I could not reproduce it on
> Darwin or Debian Linux. Is there someone -- especially on Solaris --
> who can try to reproduce this bug? How should we approach this?
>
>

On Solaris 10, I can't reproduce this on 5.12.4, 5.14.2, or blead, but
could on the system-provided 5.8.4; So this was fixed somewhere along the
road.

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.