Le 20-12-21 15:32:13, ygrek a écrit : > On Mon, 21 Dec 2020 22:03:32 +0100 > Christophe Raffalli wrote: > > > static void protect_callback(char *name, value f, value v1) > > { > > caml_acquire_runtime_system(); > > { > > CAMLparam2(f,v1); > > CAMLlocal1(res); > > res = caml_callback_exn(f, v1); > > if(Is_exception_result(res)) > > fprintf(stderr, "Egl.main_loop: " > > "WARNING: %s raised an exception\n", name) ; > > CAMLdrop; > > } > > caml_release_runtime_system(); > > } > > Values pointed by f and v1 may be moved by gc prior to caml_acquire_runtime_system call, but the values passed to the function (in registers or via stack) > will be pointing to old locations still. IOW need to pass ocaml values here by-reference (where the reference itself is registered with gc somehow), not by-value. > > -- Many thanks, this is clearly my problem and sounds completely logical! I should have see this myself! Many the documentation should say this and show an example of callback acquiring the runtime system ? I update my issue in github. Thanks again, Christophe