Closed p5pRT closed 19 years ago
This is a bug report for perl from perlbug@powermagic.net\, generated with the help of perlbug 1.33 running under perl v5.6.1.
The code at the end shows three ways of passing filehandles. Number 1 and number 3 perform as expected. Number 2 does not.
There are 3 'examplettes'. They each do the following
* Tie a file handle * Open * Sysread from the handle * Sysread from a 'copy' of the file handle
The word 'copy' here has three slightly different meaning.
The TIEHANDLE\, OPEN and READ functions just do simple prints so we can see they have been executed. (no close is done) The output is printed below.
---snip---- Q:\web\ro\test>perl -w tietest_odd.pl TIEHANDLE called OPEN called READ entered READ entered
TIEHANDLE called OPEN called READ entered
TIEHANDLE called OPEN called READ entered ---snip----
As you can see only the first example 'worked'. In examples 2 & 3 the second sysread failed (trust me\, it is the second that fails :). in (3) I expect the failure. The example that confuses me is the second. The code is:
tie *FIL2\, OddTiedHandle::; my $ptr2 = \*FIL2; open (FIL2); sysread(*FIL2\,$buf\,$blksize); sysread(*$ptr2\,$buf\,$blksize); print "\n";
The second Sysread is not executed\, and nothing I can read shows me why it should fail.
The only difference between example 1 and 2 is that example 1 has opened (*FIL2). I do not see why the filehandler reference should work differently just because the open is star-struck. I think this is a bug in Perl - but it may be in my head (and some others I have run it past).
Regards - Paul Cotter www.powermagic.net
The following code produces the above output in perl 5.6 on a Win2K server.
----code snip-----
package OddTiedHandle; use strict;
sub TIEHANDLE { my ($class) = @_; # sort of like the variable name print "TIEHANDLE called\n"; return bless \{}\,$class; }; sub READ { print "READ entered\n" ; return 1; };
sub OPEN { print "OPEN called\n"; }
my ( $len \, $buf\, $blksize) = (0\,""\,120\,);
tie *FIL1\, OddTiedHandle::; my $ptr = \*FIL1; open (*FIL1); sysread(*FIL1\,$buf\,$blksize); sysread(*$ptr\,$buf\,$blksize); print "\n";
tie *FIL2\, OddTiedHandle::; my $ptr2 = \*FIL2; open (FIL2); sysread(*FIL2\,$buf\,$blksize); sysread(*$ptr2\,$buf\,$blksize); print "\n";
tie *FIL3\, OddTiedHandle::; *DIRECT = *FIL3; open (*FIL3); sysread(*FIL3\,$buf\,$blksize); sysread(*DIRECT\,$buf\,$blksize); ---code Snip----
Flags: category=core severity=low
Site configuration information for perl v5.6.1:
Configured by Administrator at Tue Feb 6 13:01:09 2001.
Summary of my perl5 (revision 5 version 6 subversion 1) configuration: Platform: osname=MSWin32\, osvers=4.0\, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended\, useposix=true\, d_sigaction=undef usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='cl'\, ccflags ='-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX'\, optimize='-O1 -MD -DNDEBUG'\, cppflags='-DWIN32' ccversion=''\, gccversion=''\, gccosandvers='' intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=1234 d_longlong=undef\, longlongsize=8\, d_longdbl=define\, longdblsize=10 ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=4 alignbytes=8\, usemymalloc=n\, prototype=define Linker and Libraries: ld=''\, ldflags ='-nologo -nodefaultlib -release -libpath:"d:\Perl\lib\CORE" -machine:x86' libpth="d:\Perl\lib\CORE" libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib libc=msvcrt.lib\, so=dll\, useshrplib=yes\, libperl=perl56.lib Dynamic Linking: dlsrc=dl_win32.xs\, dlext=dll\, d_dlsymun=undef\, ccdlflags=' ' cccdlflags=' '\, lddlflags='-dll -nologo -nodefaultlib -release -libpath:"d:\Perl\lib\CORE" -machine:x86'
Locally applied patches: v5.6.1-TRIAL2 ACTIVEPERL_LOCAL_PATCHES_ENTRY
@INC for perl v5.6.1: D:/Perl/lib D:/Perl/site/lib .
Environment for perl v5.6.1: HOME (unset) LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=C:\Program Files\Sybase\Jaguar CTS 3.5\bin;C:\Program Files\Sybase\Jaguar CTS 3.5\dll;C:\Program Files\Sybase\Jaguar CTS 3.5\client\dll;C:\Program Files\Sybase\Shared\Sun\JDK118\bin;C:\Program Files\Sybase\Shared\PowerBuilder;C:\Program Files\Microsoft.Net\FrameworkSDK\Bin\;C:\WINNT\Microsoft.NET\Framework\v1.0.2204\;D:\Perl\bin\;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Support Tools\;c:\util;D:\Python20\;C:\PROGRA~1\NcFTP;C:\Program Files\Symantec\pcAnywhere;C:\Program Files\Sybase\Adaptive Server Anywhere 6.0\win32;C:\Program Files\Sybase\Shared\Sun\jdk118\bin;C:\Program Files\Sybase\PowerDynamo\win32;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin PERL_BADLANG (unset) SHELL (unset)
Running the sample program in the bug report under ActivePerl 623 (5.6.0) shows that the 2nd and 3rd examples do indeed only do one READ each.
Under ActivePerl 635 (5.6.1) the 2nd example does two READ's\, while the 3rd still does only one.
Under ActivePerl 806 (5.8.0) to 810 (5.8.4) [the current version] inclusive\, all three examples do two READ's each\, so this bug is evidently resolved.
@steve-m-hay - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#6939 (status was 'resolved')
Searchable as RT6939$