The Revenge of Finalizers
Ross Paterson
ross at soi.city.ac.uk
Thu Oct 17 13:10:18 EDT 2002
On Thu, Oct 17, 2002 at 10:09:06AM +0100, Simon Marlow wrote:
> > There's another problem with Simon's patch I haven't been able to pin
> > down: if you run the example, interrupt it at the right point and type
> > another expression, the finalizers run, but the expression is lost.
>
> I can get it to fail another way too:
>
> main = do
> p <- mallocBytes 64
> newForeignPtr p (print x)
> print x
> where
> x = sum [1..10000]
>
> Can't believe I didn't realise this kind of thing might be a problem
> before... guess I was too fixated on the other issues. Anyway, it
> really needs someone who is familiar with the Hugs backend to comment on
> whether either of these problems are fixable or not.
I can fix mine, though not yours: it's necessary to wrap runFinalizers()
in push(n) ... drop(), so the garbage collector will see n.
More information about the FFI
mailing list