fprintCCS_stderr (+RTS -xc) should be able to traverse into stacks that evaluated a given stack even if the latter does not come from a CAF
Tested in GHC 8.2.2, 8.4.3 and 8.6.1:
Test-good.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
import GHC.Base
data X = X Int deriving (Eq, Show)
main :: IO ()
main = (returnIO undefined) `bindIO` (\_ -> (print $ X (error "XXX")))
build.sh
#!/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.
Trac metadata
Trac field | Value |
---|---|
Version | 8.6.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |