Skip Menu |
Report information
Id: 118957
Status: open
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: shlomif [at] shlomifish.org
Cc: ais523 <ais523 [at] bham.ac.uk>
AdminCc:

Operating System: Linux
PatchStatus: (no value)
Severity: low
Type: core
Perl Version: 5.18.0
Fixed In: (no value)



Subject: Filehandle Leak With Wrong binmode
Date: Sun, 21 Jul 2013 18:56:04 +0300
To: perlbug [...] perl.org
From: Shlomi Fish <shlomif [...] shlomifish.org>
Download (untitled) / with headers
text/plain 5.1k
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. This was reported by ais523 on Freenode's #perl, so thanks go to him/her. [Please do not change anything below this line] ----------------------------------------------------------------- --- 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
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1012b
On Sun Jul 21 08:56:29 2013, shlomif@shlomifish.org wrote: Show quoted text
> > 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
CC: perl5-porters [...] perl.org
Subject: Re: [perl #118957] Filehandle Leak With Wrong binmode
Date: Mon, 22 Jul 2013 02:23:46 +0200
To: perlbug-followup [...] perl.org
From: Leon Timmermans <fawaka [...] gmail.com>
Download (untitled) / with headers
text/plain 528b
On Mon, Jul 22, 2013 at 1:58 AM, James E Keenan via RT <perlbug-followup@perl.org> wrote: Show quoted text
> 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. Show quoted text
> 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


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org