Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: [Caml-list] Tips to find the cause of a seg fault
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-12-03 (15:43)
From: Damien Doligez <damien.doligez@i...>
Subject: Re: [Caml-list] Tips to find the cause of a seg fault

On 2010-12-01, at 00:08, Philippe Veber wrote:

> Short story (details below): I'm currently writing a program relying on react, lablgl and ocamlsdl. This program segfaults on my laptop under two linux distributions (ubuntu and gentoo) but doesn't on a PC under ubuntu. The seg fault occurs with both bytecode and native executables. I don't do any marshaling nor use any typing magic; stack overflow is not likely. I humbly ask this list about means to improve valgrind or gdb outputs, which don't report informative function names, or more generally, any tip that could help me to locate the origin of the problem.

You should try to compile the OCaml runtime in debug mode: just "make ocamlrund"
in the ...ocaml/bytecode directory, then run your program with ocamlrund.

> Many thanks for the clarification. Maybe I could (partially) "unplug" the GC by setting space_overhead to 100 ? That could give an indication on the moment the problem occurs ?

The default space_overhead is already 80.  If you want the major GC
to run very slowly, set the overhead to 1000 or 10000.  But usually
you want to do the opposite, so that the crash happens soon after the
execution of the buggy code.  You can try to pepper your code with
calls to Gc.compact, for example.  In your case, I would call it just
before the pattern matching that crashes mysteriously.

-- Damien