Skip to content

GHCi segfaults on arm

I define a data type:

data Tree a = Leaf a | Tree {  left :: Tree a 
                            , right :: Tree a } deriving Show

Then I create a few named trees:

testTree0 = Leaf 0
testTree1 = Tree (Leaf 0) (Leaf 0)
testTree2 = Tree testTree0 testTree0
testTree3 = Tree testTree1 testTree1
testTree4 = Tree (Tree (Leaf 0) (Leaf 0)) (Tree (Leaf 0) (Leaf 0))

This segfaults in GHCi (works fine with non-interactive GHC):

main = print testTree3

Notes

  • testTree3 and testTree4 represent the same tree, constructed in different ways. However, testTree3 segfaults when it tries to print the second testTree1; testTree4 does not.
  • entering 'print testTree1' twice segfaults, but only if it is twice in a row.
  • strangely enough, printing testTree4 repeatedly does not segfault.
  • printing testTree0 many times in a row doesn't segfault either.
  • printing testTree2 segfaults.

It seems to be something to do with repetition or reevaluation of the same named structure. I haven't yet managed to determine whether the print is relevant or whether it's forcing the evaluation of the data structure that causes the segfault (Can't remember how to force a list but discard the result). I have attached the the output from running ghci with +RTS -Di. Let me know if there's anything else I should try.

Trac metadata
Trac field Value
Version 7.10.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC hvr
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information