Date: Thu, 16 May 1996 00:26:05 +0200 From: Bertrand Petit <elrond@memo.frmug.fr.net> To: freebsd-bugs@freebsd.org Cc: roberto@keltia.freenix.fr Subject: Bug found in getrlimit for 2.1R Message-ID: <199605152226.AAA18328@memo.frmug.fr.net>
next in thread | raw e-mail | index | archive | help
I've found a bug in the getrlinit function(). Here is a small program to demonstrate this: ----- #include <stdio.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/time.h> #include <sys/resource.h> int main() { struct rlimit Lim; if(getrlimit(RLIMIT_NOFILE,&Lim)) { printf("getrlimit() failes (%s).",strerror(errno)); } else { printf("soft=%d\nhard=%d\n",(long)Lim.rlim_cur,Lim.rlim_max); fflush(stdout); } return(0); } ----- This program outputs: ----- soft=64 hard=-1 ----- And under gdb: ----- Breakpoint 1, main () at toto.c:12 (gdb) print Lim $1 = {rlim_cur = 0x0000000000000040, rlim_max = 0x7fffffffffffffff} ----- I've searched the getrlinit source code: ----- memo$ nm /usr/lib/libc.a | grep getrlimit U _getrlimit getrlimit.o: 00000008 T _getrlimit ----- But was unable to find it on my installation nor the second CD of 2.1R! ----- memo$ find /usr/src -name getrlimit.c memo$ find /cdiso/usr/src -name getrlimit.c ----- I discovered this but while wriing a program working hard with sockets: ----- getrlimit(RLINIT_NOFILE) returned garbage for rlim_max!!! Using arbitrary hard limit. At most 255 file descriptors can be created of wich 60 are still free for sockets. ----- The reactions of this programs leads ne to this that there is also a bug in select(), more on that later when I've found what going on. Thanks.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605152226.AAA18328>