Skip to content

compiler panic

I played with cyclic lists in GHCI.
My session looked like:

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

Loading package base-1.0 ... linking ... done.
Prelude> let cl = cycle [1..5]
Prelude> take 100 cl
[1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5]
Prelude> let cl = cycle [-2,2]
Prelude> take 100 cl
[-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2,-2,2]
Prelude> let cl = cycle [-2..2]
Prelude> sum $ take 1000 cl
0
Prelude> sum $ take 10000 cl
0
Prelude> sum $ take 100000 cl
0
Prelude> sum $ take 1000000 cl
*** Exception: stack overflow
Prelude> sum $! take 1000000 cl
*** Exception: stack overflow
Prelude> foldl' (+) 0  $! take 1000000 cl

<interactive>:1:0: Not in scope: `foldl''
Prelude> List.foldl' (+) 0  $! take 1000000 cl

<interactive>:1:0: Not in scope: `List.foldl''
Prelude> Data.List.foldl' (+) 0  $! take 1000000 cl
0
Prelude> Data.List.foldl' (+) 0  $! take 10000000 cl
0
Prelude> Data.List.foldl' (+) 0  $! take 100000000 cl
0
Prelude> Data.List.foldl' (+) 0  $! take 100000000 cl
0
Prelude> Data.List.foldl' (+) 0  $! take 1000000 cl
0
Prelude> Data.List.foldl (+) 0  $! take 1000000 cl
*** Exception: stack overflow

*********************

After that I read "TyingTheKnot" page of HaWiki and
desided to repeat example with double linked list. So i
created file. It already contained some garbage from my
previous experiments but I decided it's irrelevant:

% cat test13.hs                                       
                                                    
import Control.Exception as C

data DL a = DL {prev_dl::DL, el::a, next_dl::DL}

mkDL :: [a] -> DL a
mkDL xs = let (first,last) = go last xs first
              in first

go :: DL a -> [a] -> DL a -> (DL a,DL a)
go prev [] next = (prev, next) 
go prev (x:xs) next = let this = DL prev x rest
                          (rest,fin) = go this xs next
                      in this

takeF 0 lst = []
takeF n lst = (el lst):takeF (n-1) next_dl lst

takeR 0 lst = []
takeR n lst = (el lst):takeF (n-1) prev_dl lst





main = do putStrLn "hello"
          r <- getLine
          C.catch (action r) handler
                
action :: String -> IO()
action r = if (r=="") then C.ioError (userError "input
void") 
           else print $ r++r

handler :: Exception -> IO()
% cat test14.hs                                       
                                                   
~/coding/Haskell 
% cat test13.hs                                       
                                                   
~/coding/Haskell 
import Control.Exception as C

data DL a = DL {prev_dl::DL, el::a, next_dl::DL}

mkDL :: [a] -> DL a
mkDL xs = let (first,last) = go last xs first
              in first

go :: DL a -> [a] -> DL a -> (DL a,DL a)
go prev [] next = (prev, next) 
go prev (x:xs) next = let this = DL prev x rest
                          (rest,fin) = go this xs next
                      in this

takeF 0 lst = []
takeF n lst = (el lst):takeF (n-1) next_dl lst

takeR 0 lst = []
takeR n lst = (el lst):takeF (n-1) prev_dl lst





main = do putStrLn "hello"
          r <- getLine
          C.catch (action r) handler
                
action :: String -> IO()
action r = if (r=="") then C.ioError (userError "input
void") 
           else print $ r++r

handler :: Exception -> IO()

*** end of test13.hs

After file was ready I tried to load it in my ghci
session and got this:

Prelude> :l test13.hs
Compiling Main             ( test13.hs, interpreted )
ghc-6.4: panic! (the `impossible' happened, GHC version
6.4):
        Unify.unifyTauTyLists: mismatched type lists!

Please report it as a compiler bug to
glasgow-haskell-bugs@haskell.org,
or http://sourceforge.net/projects/ghc/.

>
>

Some info about my system.

% uname -a                                            
                    
Linux mausov_comp 2.6.10-as5 #1 Fri Jun 24 13:45:31 MSD
2005 i686 Intel(R) Celeron(R) CPU 2.30GHz GenuineIntel
GNU/Linux

% gcc -v                                              
                                                    
Reading specs from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/specs
Configured with:
/var/tmp/portage/gcc-3.3.4-r1/work/gcc-3.3.4/configure
--prefix=/usr
--bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3
--includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info
--enable-shared --host=i686-pc-linux-gnu
--target=i686-pc-linux-gnu --with-system-zlib
--enable-languages=c,c++ --enable-threads=posix
--enable-long-long --disable-checking
--disable-libunwind-exceptions --enable-cstdio=stdio
--enable-version-specific-runtime-libs
--with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3
--with-local-prefix=/usr/local --enable-shared
--enable-nls --without-included-gettext
--disable-multilib --enable-__cxa_atexit
--enable-clocale=generic
Thread model: posix
gcc version 3.3.4 20040623 (Gentoo Linux 3.3.4-r1,
ssp-3.3.2-2, pie-8.7.6)

I compiled ghc-6.4 using ghc-6.2.2

My email is v_dmitry@list.ru

Hope that'l help









Trac metadata
Trac field Value
Version 6.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution ResolvedDuplicate
Component GHCi
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