
I am trying to dynamically load a shared haskell module - and it almost works... however as soon as the grabage collector thread runs it frees/moves something and the program falls over. Presumably this means I need to use a StablePtr - however I have as yet been unable to work out what exactly is the cause. I was hoping somebody with some knowledge of th einternals of GHC could help me out...
What you're doing really isn't supported, I'm afraid. The particular problem I believe you're running into is that the garbage collector doesn't know about the module you loaded so it can't distinguish pointers to static data in that module from heap pointers. You *can* achieve something like this using GHCi's dynamic linker (which is available in the RTS from any program). The interface is quite straightforward, see ghc/rts/Linker.h. You can load .o files of Haskell code, or shared libraries of C code (*not* Haskell code) using this mechanism. Cheers, Simon
participants (1)
-
Simon Marlow