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

can't open() more than 256 files on Solaris #9083

Closed
p5pRT opened this issue Oct 23, 2007 · 4 comments
Closed

can't open() more than 256 files on Solaris #9083

p5pRT opened this issue Oct 23, 2007 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 23, 2007

Migrated from rt.perl.org#46749 (status was 'rejected')

Searchable as RT46749$

@p5pRT
Copy link
Author

p5pRT commented Oct 23, 2007

From @rlegene

Created by @rlegene

Seemingly on Solaris 7 @​ sparc, Solaris 9 @​ sparc, Solaris 10
@​ intel I can't get perl to return file number 256 to me. Truss
shows that up to file descriptor #255 are returned to the script
as it is supposed to, but #256 is immediately closed by perl, and
undef is returned.

open("/dev/null", O_RDONLY) = 255
fstat(255, 0x0010F9D8) = 0
fcntl(255, F_SETFD, 0x00000001) = 0
Just got fileno 255
write(1, " J u s t g o t f i l".., 20) = 20
open("/dev/null", O_RDONLY) = 256
close(256) = 0
getcontext(0xFFBFED58)
getcontext(0xFFBFEBF8)
open("/dev/null", O_RDONLY) = 256
close(256) = 0
Perl's open() is b0rken​: Too many open files, stopped at ./256.pl line 18.
write(2, " P e r l ' s o p e n (".., 75) = 75

$ ulimit -n 1234
$ ./256.pl
[...]
Just got fileno 252
Just got fileno 253
Just got fileno 254
Just got fileno 255
Perl's open() is b0rken​: Too many open files, stopped at ./256.pl line 18.
$ cat 256.pl
#!/usr/bin/perl -w

use strict;
use warnings;
use IO​::File;

my @​a;
while (1) {
  my $fh = new IO​::File('/dev/null');
  if ($fh) {
  printf "Just got fileno %d\n", $fh->fileno;
  push @​a, $fh;
  exit if $fh->fileno > 1029;
  } else {
  last;
  }
}
open HAHA, "/dev/null" or die "Perl's open() is b0rken​: $!, stopped";

The extra open, is to make sure the fault is not in IO​::File.

.. and it's not an OS issue, because it works in C.

$ cat 256.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

main() {
  int fh;
  while (1) {
  fh = open("/dev/null", O_RDONLY);
  if (fh == -1) {
  perror("open");
  exit(1);
  }
  printf("Just got fileno %d\n", fh);
  if (fh > 1030) exit(0);
  }
}
~
robert@​thunder (0)$ make 256
gcc 256.c -o 256
$ ./256|tail -2
Just got fileno 1030
Just got fileno 1031

Perl Info

Flags:
    category=core
    severity=high

Site configuration information for perl v5.8.0:

Configured by haarbo at Sun Jan 19 13:33:31 CET 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.9, archname=sun4-solaris
    uname='sunos thunder 5.9 generic_112233-03 sun4u sparc sunw,sun-fire-280r '
    config_args='-Dcc=gcc'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=undef usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-fno-strict-aliasing',
    optimize='-O',
    cppflags='-fno-strict-aliasing'
    ccversion='', gccversion='3.2.1', gccosandvers='solaris2.9'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.0:
    /usr/local/lib/perl5/5.8.0/sun4-solaris
    /usr/local/lib/perl5/5.8.0
    /usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.8.0
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.8.0:
    HOME=/home/robert
    LANG (unset)
    LANGUAGE (unset)
    LC_CTYPE=iso_8859_1
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/robert/bin:/usr/local/bin:/home/robert/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin/:/usr/local/bin:/usr/bin:/usr/ccs/bin:/usr/ucb:/usr/sbin:/opt/gnu/bin:/usr/local/ssl:/usr/local/ssl/bin:/usr/local/mysql/bin:/opt/SUNWppro/bin:/usr/sadm/bin:/usr/local/perl:/usr/local/pim/bin:/usr/openwin/bin:/usr/local/sbin/:/usr/local/bin:/usr/bin:/usr/ccs/bin:/usr/ucb:/usr/sbin:/opt/gnu/bin:/usr/local/ssl:/usr/local/ssl/bin:/usr/local/mysql/bin:/opt/SUNWppro/bin:/usr/sadm/bin:/usr/local/perl:/usr/local/pim/bin:/usr/openwin/bin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Oct 24, 2007

From mark@mark.mielke.cc

32-bit STDIO on Solaris doesn't support > 256 file descriptors. Either
compile for 64-bit, or I believe there was a libc.a work around to
re-enable this?

In any case, it isn't a Perl limitation.

Cheers,
mark

Robert Martin-Legène (via RT) wrote​:

# New Ticket Created by Robert Martin-Legène
# Please include the string​: [perl #46749]
# in the subject line of all future correspondence about this issue.
# <URL​: http​://rt.perl.org/rt3/Ticket/Display.html?id=46749 >

This is a bug report for perl from robert@​martin-legene.dk,
generated with the help of perlbug 1.34 running under perl v5.8.0.

-----------------------------------------------------------------
[Please enter your report here]
Seemingly on Solaris 7 @​ sparc, Solaris 9 @​ sparc, Solaris 10
@​ intel I can't get perl to return file number 256 to me. Truss
shows that up to file descriptor #255 are returned to the script
as it is supposed to, but #256 is immediately closed by perl, and
undef is returned.

open("/dev/null", O_RDONLY) = 255
fstat(255, 0x0010F9D8) = 0
fcntl(255, F_SETFD, 0x00000001) = 0
Just got fileno 255
write(1, " J u s t g o t f i l".., 20) = 20
open("/dev/null", O_RDONLY) = 256
close(256) = 0
getcontext(0xFFBFED58)
getcontext(0xFFBFEBF8)
open("/dev/null", O_RDONLY) = 256
close(256) = 0
Perl's open() is b0rken​: Too many open files, stopped at ./256.pl line 18.
write(2, " P e r l ' s o p e n (".., 75) = 75

$ ulimit -n 1234
$ ./256.pl
[...]
Just got fileno 252
Just got fileno 253
Just got fileno 254
Just got fileno 255
Perl's open() is b0rken​: Too many open files, stopped at ./256.pl line 18.
$ cat 256.pl
#!/usr/bin/perl -w

use strict;
use warnings;
use IO​::File;

my @​a;
while (1) {
my $fh = new IO​::File('/dev/null');
if ($fh) {
printf "Just got fileno %d\n", $fh->fileno;
push @​a, $fh;
exit if $fh->fileno > 1029;
} else {
last;
}
}
open HAHA, "/dev/null" or die "Perl's open() is b0rken​: $!, stopped";

The extra open, is to make sure the fault is not in IO​::File.

.. and it's not an OS issue, because it works in C.

$ cat 256.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

main() {
int fh;
while (1) {
fh = open("/dev/null", O_RDONLY);
if (fh == -1) {
perror("open");
exit(1);
}
printf("Just got fileno %d\n", fh);
if (fh > 1030) exit(0);
}
}
~
robert@​thunder (0)$ make 256
gcc 256.c -o 256
$ ./256|tail -2
Just got fileno 1030
Just got fileno 1031

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

Configured by haarbo at Sun Jan 19 13​:33​:31 CET 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration​:
Platform​:
osname=solaris, osvers=2.9, archname=sun4-solaris
uname='sunos thunder 5.9 generic_112233-03 sun4u sparc sunw,sun-fire-280r '
config_args='-Dcc=gcc'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=undef usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler​:
cc='gcc', ccflags ='-fno-strict-aliasing',
optimize='-O',
cppflags='-fno-strict-aliasing'
ccversion='', gccversion='3.2.1', gccosandvers='solaris2.9'
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4
alignbytes=8, prototype=define
Linker and Libraries​:
ld='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -ldl -lm -lc
perllibs=-lsocket -lnsl -ldl -lm -lc
libc=, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking​:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches​:

---
@​INC for perl v5.8.0​:
/usr/local/lib/perl5/5.8.0/sun4-solaris
/usr/local/lib/perl5/5.8.0
/usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris
/usr/local/lib/perl5/site_perl/5.8.0
/usr/local/lib/perl5/site_perl
.

---
Environment for perl v5.8.0​:
HOME=/home/robert
LANG (unset)
LANGUAGE (unset)
LC_CTYPE=iso_8859_1
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/home/robert/bin​:/usr/local/bin​:/home/robert/bin​:/usr/local/bin​:/usr/bin​:/bin​:/usr/sbin​:/sbin​:/usr/local/bin​:/usr/local/sbin/​:/usr/local/bin​:/usr/bin​:/usr/ccs/bin​:/usr/ucb​:/usr/sbin​:/opt/gnu/bin​:/usr/local/ssl​:/usr/local/ssl/bin​:/usr/local/mysql/bin​:/opt/SUNWppro/bin​:/usr/sadm/bin​:/usr/local/perl​:/usr/local/pim/bin​:/usr/openwin/bin​:/usr/local/sbin/​:/usr/local/bin​:/usr/bin​:/usr/ccs/bin​:/usr/ucb​:/usr/sbin​:/opt/gnu/bin​:/usr/local/ssl​:/usr/local/ssl/bin​:/usr/local/mysql/bin​:/opt/SUNWppro/bin​:/usr/sadm/bin​:/usr/local/perl​:/usr/local/pim/bin​:/usr/openwin/bin
PERL_BADLANG (unset)
SHELL=/usr/local/bin/bash

--
Mark Mielke <mark@​mielke.cc>

@p5pRT
Copy link
Author

p5pRT commented Oct 24, 2007

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

@p5pRT
Copy link
Author

p5pRT commented Oct 24, 2007

@rgs - Status changed from 'open' to 'rejected'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant