Finali[zs]ers

Simon Marlow simonmar at microsoft.com
Tue Oct 15 05:44:39 EDT 2002


> I dont have cvs write access but you should mention something about
> expressing gc dependencies between ForeignPtr's. the only two 
> ways to do
> this in the current haskell systems are
> * weak pointers
> * touchForeignPtr from the finalizer of another ForeignPtr

Actually I have a feeling that in GHC it doesn't work to use
touchForeignPtr from the finalizer of one ForeignPtr in order to keep
another alive.  According to our semantics for weak pointers, I think
the two finalizers can still be run together, because pointers from a
finalizer are not followed when calculating reachability.

Hmm.  I'm not sure what to do about this.

> if the second one is not allowed by restricting us to C only 
> finalizers,
> then the first needs to be added into the FFI, (or some other 
> mechanism
> invented). I consider this functionality vital for any non-trivial use
> of ForeignPtr, and it becomes more important as we move more 
> stuff to C
> land, as C structures become more common.

Yes, this is a good point.  I'll add it to the document.

> for more info on the use of this, see the FFI touchForeignPtr
> documentation and the paper describing Weak pointers in ghc. the fact
> that multiple people saw the need for this and came up with solutions
> probably says something about its usefulness. 

Cheers,
	Simon



More information about the FFI mailing list