[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Malloc bug in scheduler

> I was wrong about the negative argument, 
> In scheduler/resources.c resources_query_nofiles() I get the following
> values: rc=0 rl.rlim_cur=2147483647 which leads to, in transport.c 
> stashprocess() i=2147483647 and then malloc(4294965232).
> Undefining HAVE_SETRLIMIT makes it work, of course.
> When doing a small test:
> #include <stdio.h>
> #include <sys/resource.h>
> main()
> {
>   struct rlimit rl;
>   printf("getrlimit(RLIMIT_NOFILE,&rl)=%d\n", getrlimit(RLIMIT_NOFILE,&rl));
>   printf("rl.rlim_cur=%d\n", rl.rlim_cur);
>   printf("getdtablesize()=%d\n", getdtablesize());
> }
> I get:
> getrlimit(RLIMIT_NOFILE,&rl)=0
> rl.rlim_cur=2147483647
> getdtablesize()=2000

	Yeah, and if you check, that result is actually RLIM_INFINITY,
	which in this case does not make much sense...

	Could you try also call to:
	if AIX has it, that is ?  (It needs to include <unistd.h>, I think.)

> This looks like the maximum number of files in the system, not open files per
> process, and it is reasonable that it is a signed 32bit number. Since Solaris
> 2.5 gives 64 on both rl.rlim_cur and getdtablesize(), HU-UX 10.20 gives 60
> on both and Digital Unix 4.0 gives 4096 on both. It seems they are not
> referring to the same thing as AIX4.2.1
> (NOFILE - Number of Open FILEs / NO of FILEs).

	My Solaris 2.5.1 gives following as hard-limits:
bash# ulimit -H -a
file size (blocks)       unlimited
core file size (blocks)  unlimited
data seg size (kbytes)   2097148
file size (blocks)       unlimited
stack size (kbytes)      2097148
cpu time (seconds)       unlimited
pipe size (512 bytes)    10
open files               1024
virtual memory (kbytes)  2097151

	With get-/setrlimit() there is code to maximize the number
	of fds in the scheduler, but nothing similar is in place
	for sysconf() and getdtablesize().  ( resources_maximize_nofiles() )

	Perhaps the correct change for AIX is not quite like below,
	but something slightly different that will utilize setrlimit(),
	and yet have sensible values in there...

> As I see it, ignore RLIMIT_NOFILE on AIX and use getdtablesize() instead.

	I changed that file to begin with:

 #include "hostenv.h"
 #include <stdio.h>
 #include <sys/types.h>

+#if defined(HAVE_SETRLIMIT) && !defined(_AIX)
 /* ================================================================ */

 #include <unistd.h>
 #include <sys/time.h>
 #include <sys/resource.h>

	However its next tests is with  HAVE_SYSCONF, and only
	then  getdtablesize()..

> ----
> Mail:	Martin Wendel, IT-Support, Uppsala university, S-751 08 Uppsala, Sweden
> Phone:	+46-18-4717780, Fax: +46-18-4717725

/Matti Aarnio <mea@nic.funet.fi>