
#15832: returnIO/bindIO destroys runtime explicit stack information in some cases -------------------------------------+------------------------------------- Reporter: infinity0 | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by infinity0): Here is an even more realistic example, which hopefully convinces you that this is a Very Important bug (at least with stack-trace printing), and closer to my real-world code: Good code: {{{#!hs data X = X Int | XX deriving (Eq, Show) mkX = X doInnocentThings a = case a of X i -> putStr "" XX -> putStr "XX" doBadThing a = case a of X i -> print i XX -> print "XX" main :: IO () main = do return undefined let a = mkX (error "XXX") doInnocentThings a doBadThing a }}} Good stack trace: {{{ *** Exception (reporting due to +RTS -xc): (THUNK_2_0), stack trace: Main.main.a, called from Main.main.a, called from Main.CAF:sat_s2O2 --> evaluated by: Main.doBadThing, called from Main.main, called from Main.CAF:sat_s2O2 --> evaluated by: Main.doBadThing, called from Main.main Test-good: XXX CallStack (from HasCallStack): error, called at Test-good.hs:16:16 in main:Main CallStack (from -prof): Main.main.a (Test-good.hs:16:16-26) Main.main.a (Test-good.hs:16:11-27) Main.CAF:sat_s2O2 (<no location info>) }}} Here the stack trace mentions "doBadThing", it is obvious which piece of code is at fault. Now: Bad code: (change `return undefined` to `_ <- return undefined` in the good code) Bad stack trace: {{{ *** Exception (reporting due to +RTS -xc): (THUNK_2_0), stack trace: Main.main.a, called from Main.main.a Test-bad: XXX CallStack (from HasCallStack): error, called at Test-bad.hs:16:16 in main:Main CallStack (from -prof): Main.main.a (Test-bad.hs:16:16-26) Main.main.a (Test-bad.hs:16:11-27) }}} There is no "evaluated by" entry, the only thing I see is the `let a =` statement being mentioned, which is perfectly fine logic-wise. There is no way to debug this, except by guessing based on knowledge of the whole codebase. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15832#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler