One obvious way to cause a stack overflow and get Segmentation fault would be to recursively push stack frames on top of each other until it booms. I’m wondering if stack overflow could happen without even pushing new stack frames.
Creating a large enough array could do it too from experience, but any other possible scenarios?
C99 uses a resizable array, which you could use and keep resizing it to a larger one. However this resizable array is implemented using
alloca. Here’s a sample code in UNIX env:And your output will look like this
allocais in themallocfamily of functions, except that it allocated memory on the stack by adjusting the stack pointer.