Is infinite recursion the only case or can it happen for other reasons? Doesn\'t the stack size grow as needed same as heap?
Sorry if this question has been asked be
The stack overflows when the stack pointer is pushed out of the memory block the operating system has allocated for the stack. Some operating systems will resize the stack as it grows (IIRC Linux does this) while in others the stack size is fixed at the start of the process or thread (IIRC Windows does this).
Possible reasons for overflowing the stack:
There are probably other reasons as well that I can't think of off the top of my head.