Conversation

With 64 bit address spaces, thread stacks should have GBs reserved by default, and programming with alloca should be encouraged. A lot of string and container work could be done at high performance with alloca and no frees if you don't let them escape.
30
545
Replying to
Gotta love the man page. Don't get carried away. "The alloca() function returns a pointer to the beginning of the allocated space. If the allocation causes stack overflow, program behavior is undefined"
2
5
It depends on the platform including the OS and compiler. You need -fstack-clash-protection with Clang and GCC on Linux to guarantee stack overflows are detected. Otherwise, you can easily skip over the guard page. It's not inherently caught from going past the end of the stack.
1
1
GCC -fstack-check doesn't provide protection in the general case and is actively dangerous on architectures without new-style checking. Clang doesn't actually implement it. -fstack-clash-protection is safe and provides full protection on architectures with proper support for it.
2
1
It's safe on an architecture with a proper implementation if you have pure Ada processes without any C code (no libc usage, etc.) or assembly code that's not doing the probes, etc. It's unsafe in the presence of code without the checks. It can actually be worse than not doing it.
1
1
Show replies