GHCI/FFI/GMP/Me madness
Abraham Egnor
abe.egnor at gmail.com
Mon Aug 9 13:09:40 EDT 2004
FWIW, I couldn't reproduce this problem on my system (i.e. str_test
always printed "1"). GHC 6.2.1, libgmp 4.1.3, debian unstable
Abe
On Mon, 9 Aug 2004 17:57:14 +0200, Remi Turk <buran at xs4all.nl> wrote:
> On Sun, Aug 08, 2004 at 07:34:04AM -0700, Sigbjorn Finne wrote:
> > Hi,
> >
> > please be aware that the RTS uses GMP as well, and upon
> > initialisation it sets GMP's 'memory functions' to allocate memory
> > from the RTS' heap. So, in the code below, the global variable
> > 'p' will end up having components pointing into the heap.
> > Which is fine, until a GC occurs and the pointed-to
> > GMP allocated value is eventually stomped on by the storage
> > manager for some other purpose.
> >
> > I'm _guessing_ that's the reason for the behaviour you're seeing.
>
> Hm, I _was_ aware of mp_set_memory_functions being used by the RTS.
> I've seen it often enough in ltrace's ;)
> It does indeed sound rather plausible (and making big allocations
> and such does indeed cause it to happen earlier).
>
> At which point my next question is: what now? I don't feel really
> confident about my GHC-hacking skills (huh? skills? where? ;) so
> does that mean I'm out of luck?
> *looks* Am I correct that I'd have to copy any GMP-allocated
> memory to my own memory before returning from C and vice-versa?
> I hope not :(
>
> Happy hacking,
> Remi "3212th unfinished project" Turk
>
>
>
> --
> Nobody can be exactly like me. Even I have trouble doing it.
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
More information about the Glasgow-haskell-users
mailing list