Why does GHC limit stack size?

Hello all, Why is there a limitation on the stack size in GHC? Like heap where we can limit the size by -M RTS option but the default is unlimited, why not let the program use as big a stack as required? If not by default, then by a separate option? Some of the functions that we write in recursive fashion will usually cause a stack overflow, but will work fine if there is more stack (suppose we are not worried about efficiency). And these functions generally look nicer and compact than their tail recursive versions. Is this is a technical hurdle, or just a checkpoint for runaway programs? Can we have an RTS flag allowing unlimited stack size? Thanks, Abhay

Hello,
Why is there a limitation on the stack size in GHC? Like heap where we can limit the size by -M RTS option but the default is unlimited, why not let the program use as big a stack as required? If not by default, then by a separate option?
Some of the functions that we write in recursive fashion will usually cause a stack overflow, but will work fine if there is more stack (suppose we are not worried about efficiency). And these functions generally look nicer and compact than their tail recursive versions.
Is this is a technical hurdle, or just a checkpoint for runaway programs?
This was discussed a while ago on the ghc users mailing list. I think there was general agreement that this was bad, but that doing something better meant a lot of work for someone (who could be trusted to "get it right" :-) http://www.haskell.org/pipermail/glasgow-haskell-users/2007-May/012467.html Regards -- Adrian Hey

Hello Abhay, Saturday, November 3, 2007, 1:46:07 PM, you wrote:
Why is there a limitation on the stack size in GHC?
because program that require 8mb stack, will probably require 8gb when processing more data :)
Can we have an RTS flag allowing unlimited stack size?
-K2000m, afair -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On Sat, 2007-11-03 at 11:40 +0000, Adrian Hey wrote:
Bulat Ziganshin wrote:
because program that require 8mb stack, will probably require 8gb when processing more data :)
So.. what? You could say the same about heap, which was rather the point of the earlier thread.
I personally would prefer a small stack. I do not write my programs with the intent that they should take up linear or more stack space and I want to know relatively quickly if they are using an excessive amount. I don't want something to use O(n) stack when it could be using O(1). Usually, it's relatively easy to fix "stack leaks" and indeed can lead to better algorithms, e.g. using foldr v. foldl.
participants (4)
-
Abhay Parvate
-
Adrian Hey
-
Bulat Ziganshin
-
Derek Elkins