Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Guillaume Yziquel <guillaume.yziquel@citycable.ch>
To: Yoann Padioleau <padator@wanadoo.fr>
Cc: Caml List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] tips to debug ocaml programs segfaulting
Date: Thu, 3 Mar 2011 19:24:53 +0100	[thread overview]
Message-ID: <20110303182453.GF4097@localhost> (raw)
In-Reply-To: <CCFEE5A2-7AD6-416C-B7FD-7DD52F371AF1@wanadoo.fr>

Le Thursday 03 Mar 2011 à 09:56:55 (-0800), Yoann Padioleau a écrit :
> Hi,
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1124940096 (LWP 24796)]
> 0x00000000004258d0 in caml_interprete ()
> (gdb) bt
> #0  0x00000000004258d0 in caml_interprete ()
> #1  0x0000000000421c32 in caml_callbackN_exn ()
> #2  0x0000000000421d16 in caml_callback_exn ()
> #3  0x00000000004095e9 in caml_thread_start ()
> #4  0x000000358ac062f7 in start_thread () from /lib64/libpthread.so.0
> #5  0x000000358a0d1e3d in clone () from /lib64/libc.so.6
> (gdb) 
> 
> 
> At this point I don't know what to do. No idea how from this backtrace to go back to the root cause of the segfault. Any tips ?

Your program seems quite complex, so it's a bit hard to tell. But since
you are using bytecode callbacks, I'd be curious to know if you are
having the same issue when compiled to native code. If not, then it
reminds me of an issue I had.

You could disassemble the caml_interprete function and follow the
execution of the bytecode interpreter. A possible segfault reason in
caml_interprete is the following. There is a 'movq *%rax' instruction
(at least on my box) from which the interpretation of bytecode is
dispatched to the appropriate case. When using bytecode closures for
callbacks, it did happen that there was one indirection too much (though
I do not remember doing anything wrong), and garbage was then fed to the
rax register. Code jumped to a garbage position, and segfaulted.

To me, that's one of the most likely segfault reasons in caml_interprete
in the presence of bytecode callbacks.

So disassemble caml_interprete, look at registers with info registers,
and check that you're not jumping to a random position.

-- 
     Guillaume Yziquel


      parent reply	other threads:[~2011-03-03 18:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-03 17:56 Yoann Padioleau
2011-03-03 18:10 ` Yoann Padioleau
2011-03-03 18:19   ` Yoann Padioleau
2011-03-03 21:08     ` ygrek
2011-03-03 18:24 ` Guillaume Yziquel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110303182453.GF4097@localhost \
    --to=guillaume.yziquel@citycable.ch \
    --cc=caml-list@yquem.inria.fr \
    --cc=padator@wanadoo.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox