RLIMIT_STACK
Maximum size of the main thread stack.
- Resource number
- 3
- Row in /proc/PID/limits
- Max stack size
- bash ulimit flag
- ulimit -s
- Unit in /proc/PID/limits
- bytes
- Group
- Memory
What happens at the limit
The process gets SIGSEGV when the stack tries to grow past the limit.
Error names: E2BIG.
Since Linux 2.6.23 this limit also sizes the space for the command line and environment: a quarter of the stack limit, with a floor of 32 pages, which is why a smaller `ulimit -s` can turn a working `exec` into E2BIG. glibc also uses the soft limit as the default thread stack size for new pthreads, and 8 MiB is the common default.
Check a running process with grep -i "Max stack size" /proc/PID/limits, or paste the whole file into the limits reader. Inspect or change one on a live process with prlimit --pid PID(util-linux).
Sources
Resource numbers are from asm-generic/resource.h; a few architectures (Alpha, MIPS, SPARC) number some limits differently. The list of syscall cards is matched by name from the card text on this site, not from the kernel source. Spot one that's wrong? Tell Rod.