[GHC] #15832: returnIO/bindIO destroys runtime explicit stack information in some cases

GHC ghc-devs at haskell.org
Tue Oct 30 06:06:23 UTC 2018


#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
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Tested in GHC 8.2.2, 8.4.3 and 8.6.1:

 Test-good.hs
 {{{#!hs
 import GHC.Base

 data X = X Int deriving (Eq, Show)

 main :: IO ()
 main = (returnIO undefined) `bindIO` (const (print $ X (error "XXX")))
 }}}

 Test-bad.hs
 {{{#!hs
 import GHC.Base

 data X = X Int deriving (Eq, Show)

 main :: IO ()
 main = (returnIO undefined) `bindIO` (\_ -> (print $ X (error "XXX")))
 }}}

 build.sh
 {{{#!shell
 #!/bin/sh
 set -e
 p="${1:-stg}"
 for i in good bad; do
   rm -rf ghc*_* Test-$i Test-$i.dump-* Test-$i.hi Test-$i.o
   ghc "-ddump-$p" -dsuppress-module-prefixes -dsuppress-uniques \
     -keep-tmp-files -dumpdir . -ddump-to-file \
     -fno-cse -prof -fprof-auto -fprof-auto-calls -fprof-cafs \
     -dinitial-unique=0 -dunique-increment=1 \
     Test-$i.hs
   ./Test-$i +RTS -xc || true
 done
 colordiff -ruw Test-*.dump-"$p" | less -R
 }}}

 Running `sh build.sh` gives the following output:
 {{{
 [1 of 1] Compiling Main             ( Test-good.hs, Test-good.o )
 Linking Test-good ...
 *** Exception (reporting due to +RTS -xc): (THUNK_2_0), stack trace:
   Main.main,
   called from Main.main,
   called from Main.main,
   called from Main.main,
   called from Main.main,
   called from Main.CAF:main
   --> evaluated by: Main.main,
   called from Main.main,
   called from Main.main,
   called from Main.CAF:main
   --> evaluated by: Main.main,
   called from Main.main,
   called from Main.main
 Test-good: XXX
 CallStack (from HasCallStack):
   error, called at Test-good.hs:6:57 in main:Main
 CallStack (from -prof):
   Main.main (Test-good.hs:6:57-67)
   Main.main (Test-good.hs:6:54-68)
   Main.main (Test-good.hs:6:46-68)
   Main.main (Test-good.hs:6:39-69)
   Main.main (Test-good.hs:6:8-70)
   Main.CAF:main (Test-good.hs:6:1-4)
 [1 of 1] Compiling Main             ( Test-bad.hs, Test-bad.o )
 Linking Test-bad ...
 *** Exception (reporting due to +RTS -xc): (THUNK_2_0), stack trace:
   Main.main,
   called from Main.main,
   called from Main.main,
   called from Main.main
 Test-bad: XXX
 CallStack (from HasCallStack):
   error, called at Test-bad.hs:6:57 in main:Main
 CallStack (from -prof):
   Main.main (Test-bad.hs:6:57-67)
   Main.main (Test-bad.hs:6:54-68)
   Main.main (Test-bad.hs:6:46-68)
   Main.main (Test-bad.hs:6:8-70)
 }}}

 As you can see, in Test-bad.hs all the entries below "evaluated by" are
 missing.

 I am not familiar with STG output, but running the script also shows you a
 diff of the STG dump. It seems innocent enough. Running `sh build.sh cmm`
 shows many more differences.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15832>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list