Core libs summary

Malcolm Wallace Malcolm.Wallace at
Fri Jun 29 09:31:53 EDT 2001

[ cross-posted to the FFI list ]

> > I remember that one of the ForeignObj-like datatypes pretty much
> > requires threads to implement it because the finaliser is an arbitrary
> > piece of Haskell code.  This would be hard to support in Hugs and I
> > expect NHC would have problems too.
> I seem to recall NHC having some difficulty with this... Malcolm?

Yes and no.  An arbitrary Haskell-code finaliser for a ForeignObj
is stored in nhc98's runtime system as a StablePtr to the code.
When the ForeignObj is garbage-collected, its finaliser is placed
onto a 'pending' queue.  Then when GC finishes, the pending queue is
executed before control returns to the main evaluation.  (Each item
on the queue is thrown away after execution).

This is all implemented, but the evaluation of the pending queue
currently causes a seg fault.  Chasing the bug wasn't a high priority
at the time (18 months ago), and I have simply never got round to
looking at it again.  There is also the problem that executing a
finaliser might itself cause another GC, but I can't remember if
I had a solution for that.


More information about the FFI mailing list