Segfault when using unboxed tuples in GHCi
If you put this module in a package:
{-# LANGUAGE MagicHash, UnboxedTuples #-}
module Bug ( box, wrap, proxy ) where
import GHC.Prim
box :: (# Proxy# a, b #) -> b
box (# x, y #) = y
wrap :: b -> Proxy# a -> (# Proxy# a, b #)
wrap x = \i# -> (# i#, x #)
proxy :: () -> Proxy# a
proxy () = proxy#
Then in GHCi you can do:
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
Prelude> import Bug
Prelude Bug> box (wrap "foo" (proxy ()))
"Segmentation fault (core dumped)
Alternatively you can crash runhaskell
if you put the above code in main.
It seems that GHCi fails to pickup usage of (# VoidRep, PtrLiftedRep #) tuples or something. The same trick works with State#
in place of Proxy#
, but not with Int#
.
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | GHCi |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |