Skip to content

Stack trace truncated too much with indirect recursion

This is to write down the improvements suggestions for the stack trace that I had after the HIW talk. Consider:

$ cat truncstack.hs 
import System.Environment
import Debug.Trace

runThisTwice x y = x y >> x y
main = getArgs >>= runThisTwice go1 . head
go1 l = runThisTwice go2 l
go2 l = runThisTwice go l
go x = traceStack x (error "done")
$ ghc --make -prof -fprof-auto truncstack.hs && ./truncstack x
[1 of 1] Compiling Main             ( truncstack.hs, truncstack.o )
Linking truncstack ...
x
Stack trace:
  Main.go (truncstack.hs:8:1-34)
  Main.runThisTwice (truncstack.hs:4:1-29)
  Main.main (truncstack.hs:5:1-42)
  Main.CAF (<entire-module>)
truncstack: done

Clearly. the programer would want go1 and go2 to be mentioned as well.

I think it would not be too hard to keep the stacktrace more complete and only truncate “real” recursion (i.e. repeating sublists in the stack), or even annotate them with the number of loops. Simon Marlow told me that one need to ensure that a change in the stack does not have unwanted effects on the profiling attributions.

I plan to look into this issue (unless someone shouts “no no don’t do that”).

Trac metadata
Trac field Value
Version 7.4.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Profiling
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information