develooper Front page | perl.perl5.porters | Postings from October 2011

=?UTF-8?Q?Re=3A_=5Bperl_=2397822=5D_=C2=ABuse_open=C2=BB_and_opening_tempfiles?==?UTF-8?Q?_causes_double_application_of_layers?=

Thread Previous | Thread Next
From:
Brian Fraser
Date:
October 16, 2011 16:49
Subject:
=?UTF-8?Q?Re=3A_=5Bperl_=2397822=5D_=C2=ABuse_open=C2=BB_and_opening_tempfiles?==?UTF-8?Q?_causes_double_application_of_layers?=
Message ID:
CA+nL+naU2S7cOZ9oJgcf6UYEkubWp9tvmq5x2BTaEYbKranOZA@mail.gmail.com
On Fri, Aug 26, 2011 at 10:16 AM, Leon Timmermans <perlbug-followup@perl.org
> wrote:

> # New Ticket Created by  Leon Timmermans
> # Please include the string:  [perl #97822]
> # in the subject line of all future correspondence about this issue.
> # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=97822 >
>
>
> This is a bug report for perl from fawaka@gmail.com,
> generated with the help of perlbug 1.39 running under perl 5.14.1.
>
> -----------------------------------------------------------------
>
> perl -E 'use open IO => "encoding(utf-8-strict)"; open my $fh, "<",
> undef or die $!; say for PerlIO::get_layers($fh)'
>
> Output:
> unix
> perlio
> encoding(utf-8-strict)
> utf8
> encoding(utf-8-strict)
> utf8
>
> -----------------------------------------------------------------
> ---
> Flags:
>    category=core
>    severity=low
> ---
> Site configuration information for perl 5.14.1:
>
> Configured by leon at Tue Jun 28 15:59:52 CEST 2011.
>
> Summary of my perl5 (revision 5 version 14 subversion 1) configuration:
>
>  Platform:
>    osname=linux, osvers=2.6.38-8-generic, archname=x86_64-linux
>    uname='linux leon-laptop 2.6.38-8-generic #42-ubuntu smp mon apr
> 11 03:31:24 utc 2011 x86_64 x86_64 x86_64 gnulinux '
>    config_args='-de -Dprefix=/home/leon/perl5/perlbrew/perls/perl-5.14.1'
>    hint=recommended, useposix=true, d_sigaction=define
>    useithreads=undef, usemultiplicity=undef
>    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
>    use64bitint=define, use64bitall=define, 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.6.1 20110409 (prerelease)', gccosandvers=''
>    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
>    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
>    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
> lseeksize=8
>    alignbytes=8, prototype=define
>  Linker and Libraries:
>    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
>    libpth=/usr/local/lib /lib /usr/lib /usr/lib/x86_64-linux-gnu
> /lib64 /usr/lib64
>    libs=-lnsl -ldl -lm -lcrypt -lutil -lc
>    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
>    libc=, so=so, useshrplib=false, libperl=libperl.a
>    gnulibc_version='2.13'
>  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.14.1:
>
>  /home/leon/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux
>    /home/leon/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1
>    /home/leon/perl5/perlbrew/perls/perl-5.14.1/lib/5.14.1/x86_64-linux
>    /home/leon/perl5/perlbrew/perls/perl-5.14.1/lib/5.14.1
>    .
>
> ---
> Environment for perl 5.14.1:
>    HOME=/home/leon
>    LANG=en_US.utf8
>    LANGUAGE=en_US:en
>    LD_LIBRARY_PATH (unset)
>    LOGDIR (unset)
>
>  PATH=/home/leon/perl5/perlbrew/bin:/home/leon/perl5/perlbrew/perls/perl-5.14.1/bin:/home/leon/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
>    PERLBREW_HOME=/home/leon/.perlbrew
>
>  PERLBREW_PATH=/home/leon/perl5/perlbrew/bin:/home/leon/perl5/perlbrew/perls/perl-5.14.1/bin
>    PERLBREW_PERL=perl-5.14.1
>    PERLBREW_ROOT=/home/leon/perl5/perlbrew
>    PERLBREW_VERSION=0.25
>    PERL_BADLANG (unset)
>    SHELL=/bin/bash
>
>
The bad-but-quick way to fix this is to replace the PerlIO_fdopen()s in
PerlIO_tmpfile() with PerlIO_openn() calls that pass ":" as the layers
argument.

That's bad because of this:
<leont> I can think of some situations where it is the wrong thing to do,
mostly because you push layers after open, instead of opening with the
layers.

So I'm thinking that the best solution would be to have a tmpfile()
variation that takes a layers argument, and have the current tmpfile() as a
wrapper around that. But I don't understand PerlIO enough to do it myself :
(

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About