program with GADTs segfaults when compiled with -prof and -auto-all
Consider the following modules Main.hs and M.hs:
module Main ( main )
where
import M
main :: IO ()
main = do let f = T [undefined, undefined]
[a] <- c f (\t -> return [r (UR undefined) t])
a
{-# OPTIONS_GHC -fglasgow-exts -fno-warn-incomplete-patterns #-}
module M ( R(..), U, r, T(..), c )
where
data T f where T :: [T f] -> T ()
data R t where
UR :: (T f -> ()) -> R (U f)
R :: R ()
data U f
c :: T f -> (T () -> a) -> a
c p@(T _) f = f p
r :: R (U f) -> T f -> IO ()
r a f = (fu a f) `seq` return ()
fu :: R (U f) -> T f -> ()
fu (UR f) = f
I get:
$ ghc --make -prof -auto-all Main
$ ./Main +RTS -p
Segmentation fault
$./Main
Segmentation fault
This is a boiled-down example taken from a large project. A couple of observations:
- I haven't been able to reproduce it using only one module
- The R constructor from type R is not used, but if removed, the segfault no longer happens
- If -auto-all is not used, the segfault does not happen
- I've been able to reproduce it both on linux and os x, using ghc 6.6.1
Trac metadata
Trac field | Value |
---|---|
Version | 6.6.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | jcpetruzza@gmail.com |
Operating system | Unknown |
Architecture | Unknown |