Conversation

Replying to
Technically, they are correct. You have the stack pointer, you can put data there and increase the pointer. That’s it. On heap, the OS’s memory management has to search for the right page, find an empty one, etc., etc.
1
Replying to and
Stacks still use the same virtual memory system as the rest of the address space. When you go deeper on the stack than you have before it still triggers acquiring pages the same way as touching newly allocated memory from a userspace allocator. Both end up coming from mmap, etc.
1
1
Rust notably used to dynamically allocate stacks in chunks from a userspace allocator instead of as a mapping with a guard page and stack probes to detect all the space being exhausted. It could still get an out-of-memory error and exhaust the stack but it wasn't fixed size.