ANNOUNCE: GHC 6.10.2 Release Candidate 1
Manuel M T Chakravarty
chak at cse.unsw.edu.au
Tue Mar 24 21:16:43 EDT 2009
> This is the first answer I got from the gtk2hs mailing list. Please
> this issue seriously.
Well there is a simple fix as Simon Marlow wrote,
> The fix is fiarly easy: use Foreign.Concurrent.mkForeignPtr with a
> foreign import.
In fact, if as Axel writes, these finalisers are Haskell functions
that are exported using foreign import wrapper, then using
Foreign.Concurrent.mkForeignPtr is actually the *simpler* thing to do
(you don't need any wrapping and exporting).
> Axel Simon wrote:
>> I think we're doomed. We have many, many little methods that take a
>> user-given function, wrap it into a foreign export wrapper which is
>> freed by using an on-destroy callback to Haskell. These functions are
>> most likely installed into some widgets (or other reference-counted
>> objects) that will be eventually destroyed by the Haskell garbage
>> collector. So, basically, we can't easily change Gtk2Hs. It will
>> involve many modifications. I can understand that not allowing
>> callbacks during GC is a great simplification in the runtime but it
>> seemed to be common practice to free Stable and function pointers
>> from within Haskell using a callback.
>> So, unless I'm wrong on why finalizers call back into Haskell land,
>> then this means that Gtk2Hs is fundamentally broken for the
>> foreseeable future.
More information about the Glasgow-haskell-users