exercising the storage manager

Peter Gammie peteg at cse.unsw.EDU.AU
Tue Jun 10 02:42:09 EDT 2003


g'day everyone,

I'm getting segv's from a program using the FFI (ghc5.0x) on MacOS X only,
i.e. not on Linux, my primary development platform.

So... does anyone have any tips for showing up dodgy uses of the FFI wrt
memory handling? What settings for GHC's garbage collector will create the
most pathological situations?

Also, I have some qualms about foreignPtrToPtr; by it's type, it seems to
be exactly what you want most of the time, but due to the "if this is the
last reference, the finalizers may run" caveat it almost always isn't.
I note that it already has some warnings attached to it, but...

- does anyone have a safe use for it that doesn't involve touchForeignPtr?

- can the FFI spec somehow group together all functions that may introduce
  memory leaks or unsafety?

cheers
peter



More information about the FFI mailing list