Subject: Re: setrlimit(RLIMIT_STACK,..) check for limit < stack usage
To: None <>
From: Giles Lean <>
List: tech-kern
Date: 11/18/2001 12:50:27
der Mouse writes:

> What is the "current usage" of the stack?  I'd argue it's where the
> stack pointer points, not the amount of VM presently allocated to the
> stack: if something has (say) gulped a megabyte of stack but has since
> unwound to where only 10K is in use, I see no obvious reason why it
> should be impossible to set the stack size limit to something between
> 10K and 1M.

I suppose that depends whether you view the stack size limit from the
kernel's perspective ("memory have I allocated for this process's
stack") or the application's point of view ("stack space am I using

If the stack size were to be able to be reduced below the actual
allocated size (i.e. set to some value > 10KB and < 1MB in your
example) should the allocated but unused memory then be released, or
just made inaccessible (which is what I think the current code does)?

current usage == allocated memory is at least simple.  Anyone looked
to see what other implementations do?