On 23 Aug 2010, at 13:12, Paul Steckler wrote:

On Mon, Aug 23, 2010 at 10:05 PM, Mark Shinwell
<mshinwell@janestreet.com> wrote:

Have you tried using gdb to determine the stack backtrace when it segfaults?
Also, if it can be done without disturbing too much code, it might be worth
trying to eliminate Dynlink from the program as a test.

I've already tried gdb, which is how I learned that the segfault
occurs during a call
to one of the query functions in my glue module.

Oh, we just added the Dynlink stuff.  There haven't been any recent
crashes until
just now.  That could be an unhappy coincidence; the real issue might
lurk in unrelated
code, as you point out.


OCaml's runtime library also has a debug version which performs additional integrity checks on the heap during garbage collection and other operations. This can help catch problems much closer to their source than the production version of the library.  I build it by:

$ cd ocaml-3.11.2/
$ ./configure <usual args>
$ cd asmrun
$ make libasmrund.a
$ cp libasmrund.a /opt/local/lib/ocaml/

Then I swap the installed libasmrun.a with libasmrund.a when a debug version is needed, and replace the original when done.  Regularly calling Gc.compact() helps triggers the additional checks more often.

I'm not sure if there is a way of using the debug version more easily --- libasmrunp.a (the profiling version) is installed by default, but libasmrund.a is not.

-anil