Front page | perl.perl5.porters |
Postings from June 2010
[perl #75780] PerlIO::via calls the CLOSE callback too late
From:
Eric Brine
Date:
June 16, 2010 02:03
Subject:
[perl #75780] PerlIO::via calls the CLOSE callback too late
Message ID:
rt-3.6.HEAD-4976-1276639273-830.75780-75-0@perl.org
# New Ticket Created by "Eric Brine"
# Please include the string: [perl #75780]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=75780 >
This is a bug report for perl from ikegami@adaelis.com,
generated with the help of perlbug 1.39 running under perl 5.12.0.
-----------------------------------------------------------------
[Please describe your issue here]
PerlIO::via calls the CLOSE callback too late.
Say you have a handle with the following PerlIO layers:
- utf8
- encoding(UTF-8)
- via(Mine)
- perlio
- unix
The close callbacks are called in this order:
1 utf8
2 encoding(UTF-8)
3 via
4 perlio
5 unix
6 Mine <-- !!
This limits what PerlIO::via::Mine::CLOSE can do. For example,
PerlIO-via-EscStatus wants to write something to the handle as it is being
closed, but can't.
The close functions should be called in this order:
1 utf8
2 encoding(UTF-8)
3 via
4 Mine <--
5 perlio
6 unix
There are 32 PerlIO::via modules on CPAN. 27 don't define a CLOSE handler.
What follows is a breakdown of the others:
PerlIO-via-SeqIO has a buggy CLOSE, no matter when it's called. (Calls
close() on the handle being closed.)
PerlIO-via-gzip has a buggy CLOSE, no matter when it's called. (Calls
close() on the handle being closed.)
PerlIO-via-ToFirePHP doesn't care when its CLOSE is called.
PerlIO-via-symlink doesn't care when its CLOSE is called.
PerlIO-via-EscStatus wants to write to the handle when it's being closed,
but it can't with the current behaviour.
IV
PerlIOVia_close(pTHX_ PerlIO * f)
{
PerlIOVia *s = PerlIOSelf(f, PerlIOVia);
- IV code = PerlIOBase_close(aTHX_ f);
SV *result =
PerlIOVia_method(aTHX_ f, MYMethod(CLOSE), G_SCALAR, Nullsv);
+ IV code = PerlIOBase_close(aTHX_ f);
if (result && SvIV(result) != 0)
code = SvIV(result);
PerlIOBase(f)->flags &= ~(PERLIO_F_RDBUF | PERLIO_F_WRBUF);
return code;
}
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=library
severity=low
module=PerlIO::via
---
Site configuration information for perl 5.12.0:
Configured by eric at Tue May 4 17:51:08 EDT 2010.
Summary of my perl5 (revision 5 version 12 subversion 0) configuration:
Platform:
osname=linux, osvers=2.6.26-2-686, archname=i686-linux
uname='linux fmdev10 2.6.26-2-686 #1 smp tue mar 9 17:35:51 utc 2010
i686 gnulinux '
config_args='-de -Dprefix=/home/eric/usr/perlbrew/perls/perl-5.12.0'
hint=recommended, useposix=true, d_sigaction=define
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='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
ccversion='', gccversion='4.3.2', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.7.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.7'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'
Locally applied patches:
---
@INC for perl 5.12.0:
/home/eric/usr/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/i686-linux
/home/eric/usr/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0
/home/eric/usr/perlbrew/perls/perl-5.12.0/lib/5.12.0/i686-linux
/home/eric/usr/perlbrew/perls/perl-5.12.0/lib/5.12.0
.
---
Environment for perl 5.12.0:
HOME=/home/eric
LANG=en_US.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/home/eric/usr/perlbrew/bin:/home/eric/usr/perlbrew/perls/current/bin:.:/home/eric/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
PERLBREW_ROOT=/home/eric/usr/perlbrew
PERL_BADLANG (unset)
SHELL=/bin/bash
-
[perl #75780] PerlIO::via calls the CLOSE callback too late
by Eric Brine