caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "ivan chollet" <ivan.chollet@free.fr>
To: <caml-list@yquem.inria.fr>
Subject: ocaml sefault in bytecode: unanswered questions
Date: Fri, 7 Aug 2009 18:29:54 +0200	[thread overview]
Message-ID: <000701ca177c$4c9ecea0$e5dc6be0$@chollet@free.fr> (raw)

[-- Attachment #1: Type: text/plain, Size: 2832 bytes --]

Hello guys,

 

I would like to ask a question about ocaml error handling. Actually many
questions that I've never dared asking on the official mailing list. I've
had a few problems sparsely with OCaml bytecode programs throwing a core
dump. When analyzing these core dumps, gdb says it's a "Segmentation fault".
Here is an example of this:

 

This GDB was configured as "i386-marcel-freebsd"...(no debugging symbols
found)...

Core was generated by `ocamlrun'.

Program terminated with signal 11, Segmentation fault.

Reading symbols from /lib/libm.so.5...(no debugging symbols found)...done.

Loaded symbols for /lib/libm.so.5

Reading symbols from /lib/libncurses.so.7...(no debugging symbols
found)...done.

Loaded symbols for /lib/libncurses.so.7

Reading symbols from /lib/libc.so.7...(no debugging symbols found)...done.

Loaded symbols for /lib/libc.so.7

Reading symbols from /usr/local/lib/ocaml/stublibs/dllunix.so...(no
debugging symbols found)...done.

Loaded symbols for /usr/local/lib/ocaml/stublibs/dllunix.so

Reading symbols from /libexec/ld-elf.so.1...(no debugging symbols
found)...done.

Loaded symbols for /libexec/ld-elf.so.1

#0  0x080606de in caml_interprete ()

 

Not very informative. So here are my questions:

 

-          What is the best way to produce and analyze core dumps in ocaml?
Should I compile in bytecode or native? Is there any special gdb "trick"
that gives you more information? Is there any special "trick" while
compiling the ocaml runtime to make it throw more information?

-          Then, my main question is actually: in bytecode, what can produce
segfaults? My ocaml code is completely standard, excepted that I use the
Marshal module. So my question is rather: outside the Marshal module, what
can cause segfault?

-          Slightly unrelated question: I have been able to generate
segfaults by running ocaml code that: 1) iterates recursively through a list
reference 2) changes the reference while still iterating on it. For example,
you just do a "List.iter myfun !myref", and within the function myfun, you
do stuff like "myref := List.filter somefilterfunction !myref". It is not
good to program like this, but for some reason I thought ocaml would not
segfault on that. Is this expected behavior? If it's not, I'll be happy to
provide some simple source code that illustrates it. (nevermind I have
actually cleaned all my code base from these dirty uses of references)

-          About ocaml bytecode interpreter and ocaml native compiler: it
seems to me, looking at the ocaml source tree, that these two parts are
completely unrelated (I'm talking about the byterun and the asmrun/asmcomp
directories), meaning that they don't share any source code. Is that
correct? 

 

Anyway guys, thanks for reading this, if you did, don't know if this makes
any sense to you.


[-- Attachment #2: Type: text/html, Size: 8238 bytes --]

             reply	other threads:[~2009-08-07 16:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-07 16:29 ivan chollet [this message]
     [not found] <16043.1656208404$1249662628@news.gmane.org>
2009-08-08  9:37 ` Sylvain Le Gall
2009-08-08 17:09 ivan chollet
     [not found] <23185.6251172305$1249751407@news.gmane.org>
2009-08-08 21:14 ` Sylvain Le Gall

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='000701ca177c$4c9ecea0$e5dc6be0$@chollet@free.fr' \
    --to=ivan.chollet@free.fr \
    --cc=caml-list@yquem.inria.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;
as well as URLs for NNTP newsgroup(s).