nhc98-1.{00,01} produce crashing programs



About this list Date view Thread view Subject view Author view

Marcin 'Qrczak' Kowalczyk (qrczak@knm.org.pl)
Thu, 28 Dec 2000 22:31:31 +0100


The following Haskell module: ------------------------------------------------------------------------ import FFI (Addr) import Monad main :: IO () main =3D do a <- malloc 100 sequence_ [do zipWithM_ (pokeElemOff a) [0..] (replicate 60 '.'++"\0") test a | i <- [0..12]] foreign import malloc :: Int -> IO Addr foreign import pokeElemOff :: Addr -> Int -> Char -> IO () foreign import test :: Addr -> IO () ------------------------------------------------------------------------ linked with the following C file: ------------------------------------------------------------------------ void pokeElemOff (char *p, int i, char x) { p[i] =3D x; } void test (char *s) { printf ("%s\n", s); } ------------------------------------------------------------------------ produces a program which prints 13*60-1 dots and one slash instead of 13*60 dots. The first byte of malloced memory is from time to time (perhaps after gc) magically increased, unless it was already '\xFF'. You may also get a crashing program if you prefer: import malloc and pokeElemOff from module FFI instead of using versions provided here. * * * Another bug: passing Int16 to C functions produces code which refers to nonexistant GET_16BIT_VALUE function. Similarly GET_64BIT_VALUE. * * * ghc from version 4.09 upwards (not released yet) has no longer a driver written in Perl, and thus confhc magic for getting its libdir does not work. I used the following hack myself, but I don't know the proper solution (ghc installed from tar.gz installs in /usr/local/lib instead of /usr/local/lib/ghc-$GHCVER by default so it won't universally work either). --- confhc.orig Thu Dec 28 00:52:42 2000 +++ confhc Thu Dec 28 00:54:16 2000 @@ -149,7 +149,7 @@ whichGHC=3D`which ghc` GHCVER=3D`${whichGHC} --version 2>&1 | sed 's/^.*version[ ]*\([0-9.]*\= ).*/\1/'` GHCSYM=3D`echo $GHCVER | tr "." " " | ( read x y z; echo $x$y; )` - GHCDIR=3D`grep '^\$libdir=3D' ${whichGHC} | head -1 | sed 's/^\$libdir= =3D[^/]*\(.*\).;/\1/'` + GHCDIR=3D${whichGHC%/*/*}/lib/ghc-$GHCVER if [ -d $GHCDIR/imports ] then GHCINCDIR=3D$GHCDIR/imports elif [ -d $GHCDIR/lib/imports ] * * * QForeign, my Haskell<->C interfacing library, now supports nhc. The first bug makes writing working non-trivial programs impossible. It's at <http://qrczak.ids.net.pl/qforeign-0.63.tar.gz>, soon will be at <http://sourceforge.net/projects/qforeign/>. -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTĘPCZA QRCZAK


About this list Date view Thread view Subject view Author view