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
[Caml-list] productivity improvement
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-10-21 (09:11)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] debugger losing contact with debuggee process
> A process I am debugging has a bus error and crashes. When it crashes, it
> loses contact with ocaml_debug. The output looks something like this:
> calling db->put with db=3c8c0 txn=0 flags=0
> Invalid argument (error number 22)
> BDB: aborting transaction

To complement Pierre's reply: if you do the dichotomy trick that
Pierre described, you'll probably find that the crash occurs in a 
C function (declared "external" in Caml).  Thus, you'll have to run
your program under a C debugger such as gdb.  To make this easier,
try to compile the C code with "-g", and link the Caml code with
"ocamlc -o myprog -custom -ccopt -g".  This way, you'll get a
standalone executable named myprog, with debug information attached.

Then, do "gdb myprog", and "run", until it crashes.  gdb "bt" command
will show you where the crash is located.  If it's in a C function
called directly or indirectly from OCaml's "interprete" function,
you're lucky: the error is indeed inside C code, and can be tracked
down just like you'd do for a C program.  If the crash is in
"interprete" or some other function of the OCaml runtime system,
things will be harder: presumably, some C code returned an illegal
Caml value, or messed up with the GC, causing a crash later in the
OCaml runtime system.  A good way to attack these problems is to
conduct a careful code review of the C/OCaml stub code, questioning
every single allocation and construction of OCaml values.

> [ I posted this question to the ocaml_beginners list. After receiving no
> replies on that list after 12hours, I conclude that the people on that
> list don't have the experience with ocamldebug to answer the question and
> am posting it to this list. ]

Your post is on-topic for this list.  However, your expectation that
you should get answers within 12 hours is ridiculous.  Even if you
paid a hefty support contract for a commercial development tool, you
would not get that.

- Xavier Leroy
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: