List Info

Thread: tell may return value from closed filehandle




tell may return value from closed filehandle
user name
2007-10-19 18:38:04
# New Ticket Created by  owlbarnowl.research.intel-research.net 
# Please include the string:  [perl #46567]
# in the subject line of all future correspondence about
this issue. 
# <URL: h
ttp://rt.perl.org/rt3/Ticket/Display.html?id=46567 >



This is a bug report for perl from dgay42gmail.com,
generated with the help of perlbug 1.35 running under perl
v5.8.8.


------------------------------------------------------------
-----
[Please enter your report here]

The following program

  # Create our test datafile
  1 while unlink 'foo';                # in case junk left
around
  open TESTFILE, ">./foo";
  close TESTFILE;

  # see if open/readline/close work on our and my variables
  {
      if (open my $T, "./foo") {
	  my $line = <$T>;
	  close $T;
      }
      print "ok 16n";
  }

  $pre = tell;
  open my $bar, "./foo";
  $post = tell;
  print "$pre $postn";

incorrectly returns 0 from tell on the second call (after
open my bar):

  barnowl:~/ivy/mm/perl owl$ perl perlbug4.pl 
  ok 16
  -1 0

Note that the following simpler code

  # Create our test datafile
  1 while unlink 'foo';                # in case junk left
around
  open TESTFILE, ">./foo";
  close TESTFILE;

  $pre = tell;
  open my $bar, "./foo";
  $post = tell;
  print "$pre $postn";

when run prints

  barnowl:~/ivy/mm/perl owl$ perl perlbug4-ok.pl 
  -1 -1

The problem is that the global PL_last_in_gv variable still
points to the 
original filehandle, which gets reused by the 'open my $bar'
statement.

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

Configured by owl at Tue Sep 25 23:53:19 PDT 2007.

Summary of my perl5 (revision 5 version 8 subversion 8)
configuration:
  Platform:
    osname=darwin, osvers=8.10.1, archname=darwin-2level
    uname='darwin barnowl.research.intel-research.net 8.10.1
darwin kernel version 8.10.1: wed may 23 16:33:00 pdt 2007;
rootnu-79
2.22.5~1release_i386 i386 i386 '
    config_args='-des -Dprefix=/opt/local
-Dccflags=-I'/opt/local/include' -Dldflags=-L/opt/local/lib
-Dvendorprefix=/opt/local -Dcc=/usr/bin/gcc-4.0'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define
usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='/usr/bin/gcc-4.0', ccflags ='-I/opt/local/include
-fno-common -DPERL_DARWIN -no-cpp-precomp
-fno-strict-aliasing -pipe -Wdeclaration-after-statement
-I/opt/local/include',
    optimize='-O3',
    cppflags='-no-cpp-precomp -I/opt/local/include
-fno-common -DPERL_DARWIN -no-cpp-precomp
-fno-strict-aliasing -pipe -Wdeclaration-after-statement
-I/opt/local/include'
    ccversion='', gccversion='4.0.1 (Apple Computer, Inc.
build 5363)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8,
byteorder=1234
    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, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags
='-L/opt/local/lib -L/usr/local/lib'
    libpth=/usr/local/lib /opt/local/lib /usr/lib
    libs=-ldbm -ldl -lm -lc
    perllibs=-ldl -lm -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false,
libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef,
ccdlflags=' '
    cccdlflags=' ', lddlflags='-L/opt/local/lib -bundle
-undefined dynamic_lookup -L/usr/local/lib'

Locally applied patches:
    

---
INC
for perl v5.8.8:
    /opt/local/lib/perl5/5.8.8/darwin-2level
    /opt/local/lib/perl5/5.8.8
    /opt/local/lib/perl5/site_perl/5.8.8/darwin-2level
    /opt/local/lib/perl5/site_perl/5.8.8
    /opt/local/lib/perl5/site_perl
    /opt/local/lib/perl5/vendor_perl/5.8.8/darwin-2level
    /opt/local/lib/perl5/vendor_perl/5.8.8
    /opt/local/lib/perl5/vendor_perl
    .

---
Environment for perl v5.8.8:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/owl
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
   
PATH=/Users/owl/bin:/usr/X11R6/bin:/usr/local/bin:/opt/local
/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )