Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] GC and preventing data relocation
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <markus@o...>
Subject: Re: [Caml-list] GC and preventing data relocation
On Fri, 21 Mar 2003, Christopher Quinn wrote:
> Markus Mottl wrote:
> >I don't quite understand this solution. How should this prevent the
> >string from being relocated if the string was allocated in the OCaml-heap?
> it wouldn't, but at least the pointer to it is changed also. and the 
> assumption i made was that the glue code knows where it is keeping its 
> pointer to the string.

Well, the glue code can surely know, but unfortunately things are more
complicated, because the C-library can't:

    +--> C-glue code
            +--> C-library
           +-----> +--> C-glue code (via "callout" function pointer)
           |              |
           |              +--> OCaml (callback)
      problem is here

Once the opaque C-library runs off with a given pointer to a string,
it may generate tons of internal datastructures that depend on this
specific location. There is just no way for me to tell the C-library
to continue elsewhere, because the C-library called me (the glue code)
before the OCaml-callback, not vice versa, and just expects me to return.

Well, I could ask the author of the C-library to add a feature that
adds offsets at each step to dependent pointers to accommodate for
relocations. But he'll probably rather kill me than rewrite 7 KLOCs of
low-level code... ;-)

> >And wouldn't be particulary portable...
> what 3rd party modification to the distributed caml runtime is!?


Markus Mottl

Markus Mottl                                   
Austrian Research Institute
for Artificial Intelligence        

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: