Hi Sylvain,
Thanks for the quick response! I just figured out the problem, however
the Gc module looks very useful for future use.

Turns out if you have intermediate functions on the C side that you
call from the C implementation of your ocaml wrappers that take
parameters of type "value", you're not supposed to use CAMLparamX on
them if it's already been used in the wrapper in implementation.
e.g.
int intermediate_fun(value v)
{
    CAMLparam1(v); /*This is wrong! Delete this line*/
    return(42 + (Int_val(v));
}
CAMLprim value wrapper_fun(value v)
{
    CAMLparam1(v);
    CAMLreturn(Val_int(intermediate_fun(v)));
}

I suppose this makes more sense after I thought about it: even though
v is passed by value to intermediate_fun, to the garbage collector
they're the same value as their contents are the same. Essentially I'm
calling CAMLparam1 on the same value twice and this seems to mess up
the gc.

I didn't see this issue mentioned in the manual or any where else. I
wonder if it has bitten others...

Anyway, thanks again for your help!
-mas


-- 
You received this message because you are subscribed to the Google Groups 
"ocaml-developer" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/ocaml-developer?hl=en
For other OCaml forums, see http://caml.inria.fr/resources/forums.en.html

Reply via email to