
Hi, I have encountered a weird behavior of ForeignPtr. I want to know how to work around this. I am using GHC 6.6.1 on Darwin. [1] Foreign.Concurrent The following code prints "called" when it is linked with -threaded RTS, but it prints nothing when it isn't. import Foreign.Marshal.Alloc import qualified Foreign.Concurrent as Conc main = do mem <- mallocBytes 10 Conc.newForeignPtr mem $ print "called" [2] Foreign.ForeignPtr The following code prints nothing when it isn't linked with -threaded RTS, but when it is, it *sometimes* prints "called" but not always. import Foreign.Marshal.Alloc import Foreign.Ptr import Foreign.ForeignPtr foreign import ccall "wrapper" mkFinalizer :: (Ptr () -> IO ()) -> IO (FunPtr (Ptr () -> IO ())) main = do mem <- mallocBytes 10 fin <- mkFinalizer $ \ _ -> print "called" newForeignPtr fin mem _______________________________________________________ - PHO - http://ccm.sherry.jp/ OpenPGP public key: 1024D/1A86EF72 Fpr: 5F3E 5B5F 535C CE27 8254 4D1A 14E7 9CA7 1A86 EF72