I notice that when I run a minimal native Linux x86-64 application it has a stack setup for it by the kernel. When I look in /proc/<pid>/maps
I see:
7ffffffde000-7ffffffff000 rwxp 00000000 00:00 0 [stack]
And when I inspect the RSP register it holds 0x7fffffffe0c0
.
What I don't understand is why the stack is only 135k bytes. I would have expected the stack mmap to be in the order of megabytes on x86-64. Or does the stack mmap have some magical properties that I am not aware of?
Is it the userland applications responsibility to manually resize the stack somehow at run-time to avoid a stack overflow? If so, by what mechanism? Or does the kernel do this automatically?