FFI Bug - Finalizer always called with NULL pointer?

Brian Hulley brianh at metamilk.com
Sat Apr 8 04:39:40 EDT 2006


Solved!
By just using the following syntax, GHC compiles everything correctly:

foreign import ccall
         "&duma_releaseFont"  -- absolutely vital for FunPtr functions
         duma_releaseFont
         :: FunPtr (Ptr RawFont -> IO ())

which now gives (correctly):

s36c_entry() {
    // SNIP
 call "ccall" suspendThread((BaseReg, NoHint))[(_c3be, NoHint)];
 call "ccall" duma_releaseFont((_s365, PtrHint)); // SPLENDID WORK GHC !!!! 
:-))))
 call "ccall" resumeThread((_c3be, NoHint));

So it seems there is something ***very*** special about the 
"&duma_releaseFont" syntax whereas I'd have thought that the meaning of:

foreign import ccall duma_releaseFont
          :: FunPtr (Ptr RawFont -> IO ()) -- DANGEROUSLY BAD :-(

should be absolutely identical. However it is not. I'm not sure whether or 
not to report this as a bug since it certainly tripped me up, and it was 
only by some lucky detective work that I discovered what was happening.

Is there supposed to be a difference or is this just a bug?

In any case - problem solved,

Brian. 



More information about the Glasgow-haskell-users mailing list