is this a bug: when <<loop>> happens stack trace is reported twice

Ömer Sinan Ağacan omeragacan at gmail.com
Mon Aug 18 09:34:10 UTC 2014


Hi all,

I just realized that when `+RTS -xc` is used and a <<loop>> error is
happened, stack trace is reported twice. This is not the case with
`error` calls, in that case stack traces are reported only once.

Here's a demonstration:

  ➜  haskell  cat loop.hs
  myFun :: Int
  myFun =
      let g = g + 1
      in g + 10

  myFun2 :: Int
  myFun2 = error "unexpected happened"

  main = print myFun
  ➜  haskell  ./loop +RTS -xc
  *** Exception (reporting due to +RTS -xc): (THUNK_STATIC), stack trace:
    Main.myFun.g,
    called from Main.myFun,
    called from Main.CAF
  *** Exception (reporting due to +RTS -xc): (THUNK_STATIC), stack trace:
    Main.myFun.g,
    called from Main.myFun,
    called from Main.CAF
  loop: <<loop>>

Here the stack trace is reported twice. If I use `myFun2` instead of `myFun`:

  ➜  haskell  ./loop +RTS -xc
  *** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
    Main.myFun2,
    called from Main.CAF
    --> evaluated by: Main.main,
    called from Main.CAF
  loop: unexpected happened

Why is this happening in the case of <<loop>> error? Is this expected
or is this a bug? I'm willing to trace the code through the RTS and
fix it but I just want to make sure that this really is a bug.

Thanks.

---
Ömer Sinan Ağacan
http://osa1.net


More information about the ghc-devs mailing list