[Haskell-cafe] Re: A guess on stack-overflows - thunks build-up and tail recursion

GŸuenther Schmidt redcom at fedoms.com
Fri Mar 20 09:10:05 EDT 2009


Thanks Bas and Ketil,

the point I wanted to stress though is that the stack overflow does
actually not occur doing the recursive algorithm, just a build-up of thunks.

The algorithm itself will eventually complete without the stack overflow.

The problem occurs when the result value is needed and thus the thunks
need to be reduced, starting with the outermost, which can't be reduced
without reducing the next one .... etc and it's these reduction steps
that are pushed on the stack until its size cause a stack-overflow.

Günther


GüŸnther Schmidt schrieb:
> Hi all,
> 
> I've been running into stack-overflow problems for some time now. Here 
> is what I gathered so far.
> 
> I used to think that the build up of thunks caused the stack overflow 
> when, as it turns out, it does not.
> 
> I apparently can have a huge thunk build up eventhough I use a 
> supposedly accumulative, tail-recursive algorithm.
> 
> Apparently it is the evaluation of this huge build-up that causes the 
> stack-overflow but not the thunk-build-up *as such*.
> 
> Do I understand this correctly?
> 
> Günther



More information about the Haskell-Cafe mailing list