Is stack based memory allocation memory allocated at run time or compile time?
The amount of stack space allocated to a process (or a thread, if you are talking about multithreading) is decided at run time, when it starts - usually by the system, which just allocates a fixed amount without regard to what the program might actually need: "allocate a megabyte and keep your fingers crossed". Alternatively, when creating a thread within a program, it is sometimes (depending on the system) possible for the programmer to specify the size of the stack required by the thread - but this, too, is done before knowing what the thread's real requirements might be.

With virtual memory, of course, what is really allocated is address space rather than actual memory, so in principle one could just increase the address space allocated to each thread and cross one's fingers a little less. But the same point remains: a fixed limit is being imposed, in advance, without knowing what is actually going to be needed.

Ultimately no reliable computer system can have both unlimited recursion and stack-based storage. Mainframes such as the IBM 360 did not use stacks for return addresses or for local storage. There are "stackless" implementations of various programming languages - any programming language could be implemented stacklessly if people really wanted to do it.

This Stack Exchange answer goes into much greater detail, more rigorously.