#4221: Calling freeHaskellFunctionPtr from C finalizer leads to crashes
---------------------------------+------------------------------------------
Reporter: ravi_n | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 6.14.1
Component: Runtime System | Version: 6.12.3
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Runtime crash
---------------------------------+------------------------------------------
Comment(by simonmar):
I found and fixed the bug, but I was confused for a while that the program
was still crashing after I'd fixed the bug. Then I noticed the program
has a pretty serious bug in it:
{{{
callFnBlob :: ForeignPtr FnBlob -> CDouble -> IO (CDouble)
callFnBlob fnblob d = withForeignPtr fnblob $
\ptrblob -> return(call_fn_blob ptrblob d)
}}}
this is an invalid use of `withForeignPtr`, because the pointer escapes
from the context (in the closure `call_fn_blob ptrblob d`). Hence the
finalizer runs before the call, and you get a crash.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4221#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs