summaryrefslogtreecommitdiff
path: root/compiler/ghci
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2018-10-14 20:32:40 +0200
committerKrzysztof Gogolewski <krz.gogolewski@gmail.com>2018-10-14 20:32:41 +0200
commit448b77b93b369745e9bfbc8b46a5b87bb73dd379 (patch)
tree8fd12e8698217f022651fe84a3ae9bf3d3e546a9 /compiler/ghci
parent68a747c702d2432cc90d2a79a6aba0e67ac3e2c0 (diff)
downloadhaskell-448b77b93b369745e9bfbc8b46a5b87bb73dd379.tar.gz
Add RubbishLit for absent bindings of UnliftedRep
Summary: Trac #9279 reminded us that the worker wrapper transformation copes really badly with absent unlifted boxed bindings. As `Note [Absent errors]` in WwLib.hs points out, we can't just use `absentError` for unlifted bindings because there is no bottom to hide the error in. So instead, we synthesise a new `RubbishLit` of type `forall (a :: TYPE 'UnliftedRep). a`, which code-gen may subsitute for any boxed value. We choose `()`, so that there is a good chance that the program crashes instead instead of leading to corrupt data, should absence analysis have been too optimistic (#11126). Reviewers: simonpj, hvr, goldfire, bgamari, simonmar Reviewed By: simonpj Subscribers: osa1, rwbarton, carter GHC Trac Issues: #15627, #9279, #4306, #11126 Differential Revision: https://phabricator.haskell.org/D5153
Diffstat (limited to 'compiler/ghci')
-rw-r--r--compiler/ghci/ByteCodeAsm.hs4
-rw-r--r--compiler/ghci/ByteCodeGen.hs1
2 files changed, 5 insertions, 0 deletions
diff --git a/compiler/ghci/ByteCodeAsm.hs b/compiler/ghci/ByteCodeAsm.hs
index 476a9b2efd..4473a9e9b2 100644
--- a/compiler/ghci/ByteCodeAsm.hs
+++ b/compiler/ghci/ByteCodeAsm.hs
@@ -460,6 +460,10 @@ assembleI dflags i = case i of
LitNumWord64 -> int64 (fromIntegral i)
LitNumInteger -> panic "ByteCodeAsm.literal: LitNumInteger"
LitNumNatural -> panic "ByteCodeAsm.literal: LitNumNatural"
+ -- We can lower 'RubbishLit' to an arbitrary constant, but @NULL@ is most
+ -- likely to elicit a crash (rather than corrupt memory) in case absence
+ -- analysis messed up.
+ literal RubbishLit = int 0
litlabel fs = lit [BCONPtrLbl fs]
addr (RemotePtr a) = words [fromIntegral a]
diff --git a/compiler/ghci/ByteCodeGen.hs b/compiler/ghci/ByteCodeGen.hs
index 022fe89306..9aaaa7db64 100644
--- a/compiler/ghci/ByteCodeGen.hs
+++ b/compiler/ghci/ByteCodeGen.hs
@@ -1539,6 +1539,7 @@ pushAtom _ _ (AnnLit lit) = do
-- representation.
LitNumInteger -> panic "pushAtom: LitInteger"
LitNumNatural -> panic "pushAtom: LitNatural"
+ RubbishLit -> code N
pushAtom _ _ expr
= pprPanic "ByteCodeGen.pushAtom"