Re: Proposed change to ForeignPtr
Malcolm Wallace wrote (about delayed finalizers):
This was the originally proposed solution for re-entrant finalisers in nhc98 and Hugs. The problem is that, certainly for nhc98, it is nigh impossible for the RTS to identify a "convenient" later moment at which to run the delayed finaliser. Well, if the nhc98 RTS can't work out a time when it will be possible to run the delayed finalizer, how in creation do you expect the Foogle finalizer or whatever Foogle GC process it invokes to do so?
George Russell <ger@tzi.de> writes:
Well, if the nhc98 RTS can't work out a time when it will be possible to run the delayed finalizer, how in creation do you expect the Foogle finalizer or whatever Foogle GC process it invokes to do so?
Quite simply, no finaliser (whether in Foogle or Haskell) should be capable of triggering a garbage collection within its call. This condition is absolutely necessary to prevent a cascade effect of cross-language garbage collections, where a finaliser in Haskell could trigger a GC in Foogle which triggers another (nested) GC in Haskell etc. Thus, if Haskell.freeSomething calls Foogle.freeSomething, and Foogle.freeSomething cannot cause a Foogle GC, then no Foogle finalisers are run yet, and so Foogle *cannot* call the Haskell world until the Haskell GC is complete. After that, it doesn't matter when the Foogle finaliser decides to run. Note that all of this assumes a sequential processing model, where control is always with one of Foogle or Haskell, never both. The FFI spec explicitly avoids introducing any requirement for concurrency, since it aims to be a minimal extension to H'98. Regards, Malcolm
participants (2)
-
George Russell -
Malcolm Wallace