On 11 December 2012 17:41, Chris Muller <ma.chris.m@gmail.com> wrote:
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.
You don't need a grumpy guy to do that. you can always do: [ i don't care what happens inside, recurse: 10000000 times ] on: StackOverflow do: [: ex pass ]. or, if you care, you can do: [ inside, recurse: 10000000 times ] on: StackOverflow do: [: ex | self showErrorAndTerminateBugger ]. all you need is a levers to control that. The idea is that you set the stack limit per process, and when it hits the limit, you get a signal, with exact information about who ran onto it. Right now, that "lowspace" is just a notification: you're going to explode...in 5..4..3..2.. now in a few lapses left, you should guess right and cut right wire (among 10000) , and if you cut wrong one... booom.. the point is that you don't know right wire, because you're not imposed any limits(rules) on your model, so you cannot find the violator.
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.
-- Best regards, Igor Stasenko.