> The following program causes SIGSEGV after a few thousands of
> iterations.
> 
> I compile with 'ghc test2.hs -o test2 -fglasgow-exts' by ghc-4.06 on
> Linux, gcc-2.95.1, glibc-2.1.2. With ghc-4.04 it crashes too.
> 
> --------------------------------------------------------------
> ----------
> import Addr
> import Weak
> 
> kill:: Addr -> IO ()
> kill a = do
>     w <- mkWeakPtr a Nothing
>     addFinalizer a $
>         deRefWeak w >> return ()
> 
> main:: IO ()
> main = sequence_ . repeat $
>     malloc 100 >>= kill >> putStrLn "x"
> 
> foreign import malloc :: Int -> IO Addr
> --------------------------------------------------------------
> ----------

The garbage collection info in the mkWeak primitive was wrong, causing
intermittent crashes.  Now fixed, many thanks for the report.

BTW: the segmentation fault on ctrl-C is another matter.  I know what's
causing it, though.

Cheers,
        Simon

Reply via email to