
On 03/01/2012 16:54, Tristan Ravitch wrote:
This might be the expected behavior but I'll ask anyway. I have what seems to be a legitimate stack overflow (due to excessive recursion and not the evaluation of a big thunk). The stack trace from -xc only shows about 13 calls on the stack (with each function that is called only appearing once).
Is it by design that functions only appear once?
Yes, and this is the area where things might change. We have to somehow make the stack finite, otherwise the data structure storing the stack would fill up the memory. Here are a few options: A) On a recursive call, truncate the stack to the previous instance of the call B) On a recursive call, do not push anything on the stack C) On a recursive call, elide some previous entries in the stack (e.g. replacing them with "...") Currently we're doing a variant of A, which is good for profiling because it means that the cost of a function call is always attributed to a stack with that function at the top. However, A doesn't satisfy all the properties we need, so certain compiler transformations aren't valid. The only option that has the right properties is B, but that isn't so useful for profiling. C is more useful for stack traces, because there is more information towards the top of the stack - the last few calls are correct, but information deeper down the stack is lost. This is what Tristan Allwood used in his "Finding the Needle" paper. Unfortunately C doesn't have the right transformational properties either. Cheers, Simon