Skip to content

GHCi 5.02.3 dumps core

(My e-mail is matti.nykanen@cs.helsinki.fi, just in
case my new SourceForge registration has problems.)

I get the following erratic behaviour - a SIGSEGV from
GHCi.
(The OS is some variant of Red Hat in use here at CS.
Dept of University of Helsinki (the birthplace of
Linux). The hardware is some generic Intel-based
desktop PC.)

----------------------------------------------------------------------------
valkokari$ ghci
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version
5.02.3, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package std ... linking ... done.
Prelude> :l SegFault
Compiling SegFault         ( SegFault.hs, interpreted )
Ok, modules loaded: SegFault.
SegFault> insert 1 2 None
Segmentation fault
valkokari$
---------------------------------------------------------------------------

The file I loaded is as follows (I hope the
xEmacs-generated
indentation came through):

---------------------------------------------------------------------------
module SegFault where

data Color = Red 
	   | Black
	     deriving Show

data Ord k => Tree k d = None 
		       | Node{color::Color,
			      key::k,
			      item::d,
			      left::(Tree k d),
			      right::(Tree k d)}
			 deriving Show

insert k i t = (insert2 t) {color=Black}
    where insert2 None = Node{color=Red,
			      key=k,
			      item=i,
			      left=None,
			      right=None}
---------------------------------------------------------------------------

If write "where insert2 x = ..." instead, I get
something different (which may make more sense to you
than me):

---------------------------------------------------------------------------
valkokari$ ghci
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version
5.02.3, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package std ... linking ... done.
Prelude> :l BadEta.hs
Compiling BadEta           ( BadEta.hs, interpreted )
Bad eta expand
    (\ k{-aX8-} d{-aXa-} t_aXm zddOrd{-aXr-} ->
       let {
         zdmNode{-aWS-}
           = \ eta_s1e7 eta_s1e9 eta_s1eb eta_s1ed
eta_s1ef ->
               BadEta.Node{-rRX-}
                 @ k{-aX8-}
                 @ d{-aXa-}
                 zddOrd{-aXr-}
                 eta_s1e7
                 eta_s1e9
                 eta_s1eb
                 eta_s1ed
                 eta_s1ef
       } in
         \ k{-rS6-} i{-rS7-} t{-rS8-} tpl_X1J ->
           BadEta.zdwNode{-rSs-}
             @ k{-aX8-}
             @ d{-aXa-}
             k{-rS6-}
             i{-rS7-}
             (BadEta.zdwNone{-rSr-} @ k{-aX8-} @ d{-aXa-})
             (BadEta.zdwNone{-rSr-} @ k{-aX8-} @ d{-aXa-})
             tpl_X1J)
      @ k{-aX8-} @ d{-aXa-} @ t_aXm eta_s1ei eta_s1eA
eta_s1eC eta_s1eE
    BadEta.Tree{-rRL-} k{-aX8-} d{-aXa-}
Ok, modules loaded: BadEta.
BadEta> insert 1 2 None
Segmentation fault
valkokari$
--------------------------------------------------------------------------

That is, then GHCi first complains about a bad eta
expansion, but nevertheless claims to have successfully
loaded the module, but still ends up crashing.

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