Open p5pRT opened 20 years ago
Consider the following short program:
# using Symbol to support older perls use Symbol; for (1..2) { my $dup = Symbol::gensym(); open $dup\, "\<&DATA" or die "Can't dup DATA: $!"; print "DATA: " . tell(DATA) . "\n"; print "dup : " . tell($dup) . "\n"; #seek $dup\, tell(DATA)\, 0; # rewind to the beginning \<$dup>; }
__DATA__ foo bar
w/o perlio we get:
DATA: 309 dup : 309 DATA: 318 dup : 318
the DATA fh pointer is correctly moved along with 'dup' as per dup(2).
w/ perlio we get:
DATA: 309 dup : 309 DATA: 309 dup : 313
the DATA fh pointer is frozen and doesn't get moved to the same pointer as the 'dup' fh.
as rgs quoted on irc:
\
and Nicolas has followed up:
\
This is observed with any perl 5.8.x
[stas - Mon Jan 05 15:15:57 2004]:
This is a bug report for perl from stas@stason.org\, generated with the help of perlbug 1.34 running under perl v5.8.1.
----------------------------------------------------------------- [Please enter your report here]
Consider the following short program:
# using Symbol to support older perls use Symbol; for (1..2) { my $dup = Symbol::gensym(); open $dup\, "\<&DATA" or die "Can't dup DATA: $!"; print "DATA: " . tell(DATA) . "\n"; print "dup : " . tell($dup) . "\n"; #seek $dup\, tell(DATA)\, 0; # rewind to the beginning \<$dup>; }
__DATA__ foo bar
w/o perlio we get:
DATA: 309 dup : 309 DATA: 318 dup : 318
the DATA fh pointer is correctly moved along with 'dup' as per dup(2).
w/ perlio we get:
DATA: 309 dup : 309 DATA: 309 dup : 313
the DATA fh pointer is frozen and doesn't get moved to the same pointer as the 'dup' fh.
as rgs quoted on irc:
\
that's what my dup(2) manpage says \ "After successful return of dup or dup2\, the old and new descriptors may be used interchangeably." and Nicolas has followed up:
\
problem (presumably) is that duping by file number means that the original file handle has buffered data\, while the new one does not. so underlying Unix fh is not at the same file offset as the return from ftell might lead you to think This is observed with any perl 5.8.x
I wondering if either case you have above is correct. On Linux\, I see the following...
steve@kirk:\~$ PERLIO=:stdio perl rt_24818.pl DATA: 279 dup : 287 DATA: 279 dup : 287 steve@kirk:\~$ PERLIO=:perlio perl rt_24818.pl DATA: 279 dup : 279 DATA: 279 dup : 283
According to dup(2)\, each file descriptor should be unique\, so the handling by :stdio seems to be fine.
Looking at the PERLIO_DEBUG output\, one thing sticks out\, but I don't know if it is incorrect. It appears that the :unix layer is sending the wrong parameters to PerlIOBase_dup.
For example\, with :stdio PerlIOBase_dup stdio f=3c00e214 o=3c00e210 param=0
with :perlio PerlIOBase_dup perlio f=3c00e214 o=3c00e210 param=0
with :mmap PerlIOBase_dup mmap f=3c00e214 o=3c00e210 param=0
with :unix PerlIOBase_dup unix f=3c00e214 o=3c00c980 param=0
On :unix\, the address of the original filehandle is not getting sent in. Maybe this is a bug\, maybe not. It is something to look into further though.
The RT System itself - Status changed from 'new' to 'open'
Steve Peters via RT wrote:
[stas - Mon Jan 05 15:15:57 2004]:
This is a bug report for perl from stas@stason.org\, generated with the help of perlbug 1.34 running under perl v5.8.1.
----------------------------------------------------------------- [Please enter your report here]
Consider the following short program:
# using Symbol to support older perls use Symbol; for (1..2) { my $dup = Symbol::gensym(); open $dup\, "\<&DATA" or die "Can't dup DATA: $!"; print "DATA: " . tell(DATA) . "\n"; print "dup : " . tell($dup) . "\n"; #seek $dup\, tell(DATA)\, 0; # rewind to the beginning \<$dup>; }
__DATA__ foo bar
w/o perlio we get:
DATA: 309 dup : 309 DATA: 318 dup : 318
the DATA fh pointer is correctly moved along with 'dup' as per dup(2).
w/ perlio we get:
DATA: 309 dup : 309 DATA: 309 dup : 313
the DATA fh pointer is frozen and doesn't get moved to the same pointer as the 'dup' fh.
as rgs quoted on irc:
\
that's what my dup(2) manpage says \ "After successful return of dup or dup2\, the old and new descriptors may be used interchangeably." and Nicolas has followed up:
\
problem (presumably) is that duping by file number means that the original file handle has buffered data\, while the new one does not. so underlying Unix fh is not at the same file offset as the return from ftell might lead you to think This is observed with any perl 5.8.x
I wondering if either case you have above is correct. On Linux\, I see the following...
steve@kirk:\~$ PERLIO=:stdio perl rt_24818.pl DATA: 279 dup : 287 DATA: 279 dup : 287
I get the same with PERLIO=:stdio as you do\, Steve. The w/o perlio test was with perl that had no perlio enabed. Here it is again:
/tmp> env PERLIO=:perlio perl-5.8.6-ithread xxx DATA: 277 dup : 277 DATA: 277 dup : 281 /tmp> env PERLIO=:stdio perl-5.8.6-ithread xxx DATA: 277 dup : 285 DATA: 277 dup : 285 /tmp> perl-5.8.6-nouseperlio xxx DATA: 277 dup : 277 DATA: 285 dup : 285
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
Migrated from rt.perl.org#24818 (status was 'open')
Searchable as RT24818$