Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filehandle Leak With Wrong binmode #13116

Open
p5pRT opened this issue Jul 21, 2013 · 4 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Jul 21, 2013

Migrated from rt.perl.org#118957 (status was 'open')

Searchable as RT118957$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 21, 2013

From @shlomif

Created by @shlomif

The following program (when run on Mageia Linux x86-64 Cauldron using
perl-5.18.0 from perlbrew and on other systems other people tried
on IRC) results at "Too many open files at hv.pl line 2."

for my $x (1 .. 10000) {
  open my $temp, '>', "/tmp/t" or die "$!";
  binmode $temp, "​:unix";
  close $temp;
}

The problem is due to the «binmode $temp, "​:unix";» which is wrong, but should
be handled more carefully.

This was reported by ais523 on Freenode's #perl, so thanks go to him/her.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.18.0:

Configured by shlomif at Fri May 24 18:23:32 IDT 2013.

Summary of my perl5 (revision 5 version 18 subversion 0) configuration:
   
  Platform:
    osname=linux, osvers=3.8.13-desktop-1.mga3, archname=x86_64-linux
    uname='linux telaviv1.shlomifish.org 3.8.13-desktop-1.mga3 #1 smp tue may
14 19:05:25 utc 2013 x86_64 x86_64 x86_64 gnulinux ' config_args='-de
-Dprefix=/home/shlomif/apps/perl/brew/perls/perl-5.18.0
-Aeval:scriptdir=/home/shlomif/apps/perl/brew/perls/perl-5.18.0/bin'
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.7.2', 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/../lib64 /usr/lib/../lib64 /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.17.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.17'
  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.18.0:
    /home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.18.0
    /home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.16.3
    /home/shlomif/apps/perl/modules/lib/site_perl/5.18.0
    /home/shlomif/apps/perl/modules/lib/site_perl/5.16.3
    /home/shlomif/apps/perl/modules/lib/perl5/5.18.0
    /home/shlomif/apps/perl/modules/lib/perl5/5.16.3
    /home/shlomif/apps/perl/brew/perls/perl-5.18.0/lib/site_perl/5.18.0/x86_64-linux
    /home/shlomif/apps/perl/brew/perls/perl-5.18.0/lib/site_perl/5.18.0
    /home/shlomif/apps/perl/brew/perls/perl-5.18.0/lib/5.18.0/x86_64-linux
    /home/shlomif/apps/perl/brew/perls/perl-5.18.0/lib/5.18.0
    .


Environment for perl 5.18.0:
    HOME=/home/shlomif
    LANG=en_GB.UTF-8
    LANGUAGE=en_GB:en
    LC_ADDRESS=en_US.UTF-8
    LC_COLLATE=en_US.UTF-8
    LC_CTYPE=en_US.UTF-8
    LC_IDENTIFICATION=en_GB.UTF-8
    LC_MEASUREMENT=en_GB.UTF-8
    LC_MESSAGES=en_US.UTF-8
    LC_MONETARY=en_US.UTF-8
    LC_NAME=en_GB.UTF-8
    LC_NUMERIC=en_GB.UTF-8
    LC_PAPER=en_US.UTF-8
    LC_SOURCED=1
    LC_TELEPHONE=en_US.UTF-8
    LC_TIME=en_GB.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/shlomif/apps/perl/brew/bin:/home/shlomif/apps/perl/brew/perls/perl-5.18.0/bin:/home/shlomif/apps/gwenview/bin:/home/shlomif/apps/perl/modules/local/bin:/home/shlomif/apps/perl/modules/bin:/opt/valgrind-trunk/bin:/home/shlomif/apps/latemp/bin:/home/shlomif/apps/quadpres/bin:/home/shlomif/apps/wml/bin:/home/shlomif/bin:/home/shlomif/bin:/home/shlomif/apps/gwenview/bin:/usr/local/bin:/usr/bin:/usr/games:/usr/lib64/qt4/bin
    PERL5LIB=/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.18.0:/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.16.3:/home/shlomif/apps/perl/modules/lib/site_perl/5.18.0:/home/shlomif/apps/perl/modules/lib/site_perl/5.16.3:/home/shlomif/apps/perl/modules/lib/perl5/5.18.0:/home/shlomif/apps/perl/modules/lib/perl5/5.16.3
    PERLBREW_BASHRC_VERSION=0.58
    PERLBREW_HOME=/home/shlomif/.perlbrew
    PERLBREW_MANPATH=/home/shlomif/apps/perl/brew/perls/perl-5.18.0/man
    PERLBREW_PATH=/home/shlomif/apps/perl/brew/bin:/home/shlomif/apps/perl/brew/perls/perl-5.18.0/bin
    PERLBREW_PERL=perl-5.18.0
    PERLBREW_ROOT=/home/shlomif/apps/perl/brew
    PERLBREW_VERSION=0.64
    PERL_AUTOINSTALL=--skipdeps --alldeps
    PERL_BADLANG (unset)
    PERL_MM_USE_DEFAULT=1
    SHELL=/bin/bash

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 21, 2013

From @jkeenan

On Sun Jul 21 08​:56​:29 2013, shlomif@​shlomifish.org wrote​:

This is a bug report for perl from shlomif@​iglu.org.il,
generated with the help of perlbug 1.39 running under perl 5.18.0.

-----------------------------------------------------------------
[Please describe your issue here]

The following program (when run on Mageia Linux x86-64 Cauldron using
perl-5.18.0 from perlbrew and on other systems other people tried
on IRC) results at "Too many open files at hv.pl line 2."

for my $x (1 .. 10000) {
open my $temp, '>', "/tmp/t" or die "$!";
binmode $temp, "​:unix";
close $temp;
}

The problem is due to the �binmode $temp, "​:unix";� which is wrong,
but should
be handled more carefully.

Apart from the fact that it results in this error, what is "wrong" about
qq{binmode $temp, "​:unix"}?

Incidentally, on my Linode the threshold for triggering this problem was​:
1020​: success
1021​: error message as reported

Thank you very much.
Jim Keenan

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 21, 2013

The RT System itself - Status changed from 'new' to 'open'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 22, 2013

From @Leont

On Mon, Jul 22, 2013 at 1​:58 AM, James E Keenan via RT
<perlbug-followup@​perl.org> wrote​:

Apart from the fact that it results in this error, what is "wrong" about
qq{binmode $temp, "​:unix"}?

:unix always acts as a bottom layer. So pushing it on top of an
existing handle will make it (mostly) ignore the existing layers.

Incidentally, on my Linode the threshold for triggering this problem was​:
1020​: success
1021​: error message as reported

Given you start with 3 open fd's that aligns with a fd-max of 1024

Leon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.