To all,

This is my first posting to the gtk2hs-devel mailing list because I came 
across a bug that I think I've fixed, but I wasn't getting any response 
on the bug tracking website, so I wanted to run it by you guys before 
submitting a patch.  I listed the bug in question at:

http://hackage.haskell.org/trac/gtk2hs/ticket/1212

The gist of the bug is that signals that have the form Signal self (IO 
()), such as buttonActivated will crash if you link a printf callback to 
them.

The reason is because the printf function returns undefined in order to 
get around having to use the FlexibleInstances extension, but the gtk2hs 
callback evaluation uses rts_evalIO to evaluate the function and it 
evaluates the return value (undefined) to weak head normal form and crashes.

I made a patched version of gtk2hs substituting in rts_evalLazyIO (see 
bug page for details) instead and this fixed the problem.  However, I 
don't know if this is an ideal solution since maybe it might lead to 
space leaks.  I was hoping you guys could comment on whether or not it's 
important to use the stricter rts_evalIO.

There are two other possible solutions.

One is to patch the printf code to use FlexibleInstances to prevent it 
from having to return undefined, but I don't think this is the correct 
solution since I don't see why gtk2hs would want to be strict in the 
return value in the first place since it doesn't seem to ever be used.

Another solution comes from observing that sometimes printf's return 
value is handled gracefully by ghc, which you can sometimes get to 
return a GHC.Prim.Any, which can be safely evaluated.  I haven't yet 
figured out how it decides when to return an undefined or a 
GHC.Prim.Any, though.

Gabriel Gonzalez

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Gtk2hs-devel mailing list
Gtk2hs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel

Reply via email to