Hi all ! I've encountered a strange bug while preparing a caml module with C function. Depending on the execution of a caml-defined function, the toplevel is evaluated or not, leading to a segfault when calling a caml callback from C. The code of the C part is: <--- #include #include #include CAMLprim value f(unit) { CAMLparam0(); caml_callback(*caml_named_value("test_printf"),Val_unit); CAMLreturn(Val_unit); } <--- The code of the caml part is: <--- let f () = Printf.printf "blalba\n"; flush_all () let () = Callback.register "test_printf" f module Test= struct external f : unit -> unit = "f" let f2 () = Printf.printf "f2\n"; flush_all () end <--- The code that uses the module is: <--- (* This needs to be executed *) let () = Test.Test.f2 () let () = Test.Test.f () <--- Step to reproduce: Compile all using the following sequence: gcc -c -o test_stubs.o ./test_stubs.c -fPIC ocamlmklib -o test_stubs ./test_stubs.o ocamlopt -c test.ml ocamlopt -a -cclib -ltest_stubs -o test.cmxa test.cmx ocamlopt -c bla.ml ocamlopt -I . test.cmxa bla.cmx -o bla Then, if you comment the first call to f2 in bla.ml, then the toplevel is not evaluated before executing the C function, leading to a segfault.. Is this a bug or am I missing something ? Romain PS: files attached