[ocaml-ctypes] Binding that works in bytecode, segfaults in native code

Jeremy Yallop yallop at gmail.com
Tue Oct 14 12:09:08 BST 2014


On 8 October 2014 14:19, Hezekiah M. Carty <hez at 0ok.org> wrote:
> In the mean time are there any suggestions or techniques you can recommend to
> help track down the cause of this segfault?

I think A. Hauptmann's advice elsewhere is worth repeating here, for
the benefit of anyone who runs into similar issues:

    "Use Gc.compact, not just Gc.full_major. And put it in a often
called function of your library code, not only at application level. I
always overlay any suspicious function with a wrapper of this scheme:

     let f .. =
       Gc.compact ();
       let x = f .. in
       Gc.compact ();
       x

    And then run your application with valgrind. Valgrind did find
this error instantly."
    (https://github.com/hcarty/ocaml-gdal/pull/3)


More information about the Ctypes mailing list