I don't understand how setting a fixed-size stack could ever be useful. No one would risk blowing up a production app only because they guessed wrong about the stackDepthLimit, so for production it would always be set to 0.
I kind of disagree: any system has limits, and most server software is set up to enforce limits earlier (maximum connections, file descriptors per process, â¦) and deal as gracefully as possible with them, to protect itself from external abuse or internal errors. Yes this might involve some guessing, so what.
You can't accurately guess an arbitrary stack limit and still have it be effective for what you want it to do (application stability). The limit will be exceeded at 3am and grumpy on-call support will increase it so that server will run out of memory first anyway. Server software needs to enforce its memory limit anyway, so that may as well be also the solution for a runaway stack. One solution for two problems.
I would rather be able to deal with an infinite recursion and return an internal server error, than have the whole server crash.
If the app registers with LowSpaceSemaphore and implements #freeSomeSpace then the whole server wouldn't crash.