Running a "final" finaliser

Adrian Hey ahey at
Tue Jan 6 07:47:23 EST 2004

On Monday 05 Jan 2004 3:14 pm, Simon Marlow wrote:
> > The other complication I can see is that ForeignPtr finalisers can't
> > be Haskell. So I have to call the Haskell finalisation from C.
> > Is that safe? I'm afraid I still don't fully understand why Haskell
> > finalisers are unsafe or why (if) calling Haskell from a C finaliser
> > (which then called C land again) would be any safer.
> If you don't mind your code being non-portable, then Foreign.Concurrent
> provides Haskell finalisers.

Oh yes, so it does :-) I'd just been looking at the FFI documentation
(only). Thanks for pointing that out.

> This support will be available only on
> Haskell implementations which implement pre-emptive concurrency (i.e.
> just GHC for now).

OK, I think understand now thanks to Alistair Reids explanation. I had
been trying to keep my code portable (it's a library binding I hope
to make available to Haskell folk sometime soon). But this seems
to be quite difficult. AFAICS the situation is that the only really
portable solution to this problem is for the reference counting thing
(or doubly linked lists or whatever) to be done in C (which I guess is
what everybody's been saying all along :-).

Adrian Hey  

More information about the Glasgow-haskell-users mailing list