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
MSVC++ and Clang with the proper Windows ABI always have full protection from the issue since the Windows ABI has taken care of this properly for ages. MinGW is unsafe in general and lacks multiple protections + has flawed implementations. It probably gets this wrong too...
1
Show replies