From: liljeber@hydra.Helsinki.FI (Mika Liljeberg) Subject: Re: I can malloc more memory than I have. Date: 29 Oct 1992 12:33:13 GMT
In article <BwuurJ.G3A@ra.nrl.navy.mil> eric@tantalus.nrl.navy.mil (Eric Youngdale) wrote:
> In article <LILJEBER.92Oct29003741@hydra.Helsinki.FI> liljeber@hydra.Helsinki.FI (Mika Liljeberg) writes:
>>Hmm, I'd say the bug is in the kernel. This is from fs/exec.c, dump_core():
>>
>>/* See if we have enough room to write the upage. */
>> if(current->rlim[RLIMIT_CORE].rlim_cur < PAGE_SIZE/1024) return 0;
>> ^^^^^^^^^^^^^^
>> Should be just 1024, no?
>
> No, this is correct. The rlimit is specified in blocks, not in bytes.
> The upage is just that, a page, and takes up 4096 bytes. Thus we need to see
> if current->rlim[RLIMIT_CORE].rlim_cur < 4 before we try and write the upage.
From the SunOS manpage for setrlimit():
RLIMIT_CORE the largest size, in bytes, of a core
^^^^^^^^
file that may be created.
_nowehere_ does this get divided by the block size in the kernel.
>>Tcsh normally computes the limit like this: actual_value = (value +
>>0.5) * unit. The default unit for coredumpsize is 1024 bytes.
>>Therefore, limit coredumpsize 0 sets the limit to 512 bytes. This
>>easy get around. If you give the unit explicitly, tcsh does not
>>attempt to round it:
>
> This could be the problem right here. Bash is setting the rlimit in
> assuming that the unit is in disk blocks and tcsh is setting it thinking that
> the unit is bytes.
> Under bash, I type "help ulimit", and I get:
>
>> If LIMIT is given, it is the new value of the specified resource.
>> Otherwise, the current value of the specified resource is printed.
>> If no option is given, then -f is assumed. Values are in 1k
>> increments, except for -t, which is in seconds, and -p, which is in
>> increments of 512 bytes.
Yes, yes. But the arguments for bash's ulimit have nothing to do with
how setrlimit() works. I admit that the way tcsh calculates the limit
value is a bit funny, but it seems to work on other systems.
> -Eric
> --
> Eric Youngdale
Mika