I can’t speak on all platforms, but as it happens, I just spent some time working with Windows.exe files (I mean, actually studying their binary format), I know, in a sense, we all work with executable files here;)). I am sure that most other platforms have similar capabilities, but I am not immediately familiar with them.
Part of the file format itself includes two values related to the current discussion:
typedef struct _IMAGE_OPTIONAL_HEADER { ... DWORD SizeOfStackReserve; DWORD SizeOfStackCommit; ... } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
From MSDN:
SizeOfStackReserve
The number of bytes to reserve for the stack. Only memory specified by a member of SizeOfStackCommit committed at boot time; the rest is available one page at a time until this reserve size is reached.
SizeOfStackCommit
The number of bytes to commit for the stack.
In other words, the linker sets the maximum size for the program stack. If you click the maximum size, you will overflow - no matter how you click the maximum size. You can write a simple program to do this in one line of code by simply highlighting one stack variable (say, an array) that is larger than the maximum stack size. Or you can do this through infinite (or finite, but very deep) recursion, or simply by allocating too many stack variables.
The Microsoft component sets this default value to 1 MB on X86 platforms (4 MB on Itanium systems). It seems small at first glance, for a modern system. However, more modern versions of Windows interpret these values in a slightly different way. Instead of completely restricting the stack, it limits the physical memory that the stack will use. If your stack grows further, virtual memory will be involved, so you should still be good ... if you have enough virtual memory.
remember, that may be enough memory, even in modern systems with a huge amount of RAM and lots of virtual memory on disk. You just need to allocate really large amounts of data.
So a long story: is stack overflow possible without infinite recursion? Definitely. Is it possible? In fact, if you do not select really huge objects.