From: "ivan chollet" <ivan.chollet@free.fr>
To: "'Cedric Auger'" <Cedric.Auger@lri.fr>, <caml-list@yquem.inria.fr>
Subject: RE: [Caml-list] ocaml sefault in bytecode: unanswered questions
Date: Sat, 8 Aug 2009 11:17:42 +0200 [thread overview]
Message-ID: <000301ca1809$1658efa0$430acee0$@chollet@free.fr> (raw)
Cedric,
I use the Unix library, can it cause segfaults also? (If yes, I would expect
the ocaml bytecode runtime system to produce a nice stacktrace though)
That's the only library I use, the rest of the code fits into the OCaml core
category and also some use of the Standard modules.
FYI, Marshal can definitely produce segfault, therefore my question was:
apart from the Marshal module, what can produce segfaults?
You basically state that stuff like let l = !myref in List.iter myfun l
(where myfun modifies !myref) wouldn't produce segfault.
Why? It would mean that doing "let l = !myref" creates a brand new OCaml
entity, l, ie a brand new allocation on the heap, and then, messing around
with !myref inside myfun would be of course 100% safe. Is that what OCaml
runtime does?
Nevertheless, I dont like OCaml runtime producing segfaults. What makes the
debugging process - and therefore the development process - deterministic is
precisely the ability to get the cause of every compile time/runtime error.
OCaml is pretty good at compile time and no doubt the typechecking feature
is useful. In an ideal world, OCaml should also classify runtime errors
nicely or throw nice stacktraces. I guess that was at least the original
design goal of the OCaml team but I may be wrong.
Ivan
-----Original Message-----
From: Cedric Auger [mailto:Cedric.Auger@lri.fr]
Sent: vendredi 7 août 2009 20:20
To: ivan chollet
Subject: Re: [Caml-list] ocaml sefault in bytecode: unanswered questions
ivan chollet a écrit :
>
> Hello guys,
>
> I would like to ask a question about ocaml error handling. Actually
> many questions that Ive never dared asking on the official mailing
> list. Ive had a few problems sparsely with OCaml bytecode programs
> throwing a core dump. When analyzing these core dumps, gdb says its 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?
>
About any binding can cause segfaults, if the binded library is not
'safe', what library did you use?
For Marshall I am not expert; but I know it will likely produce
segfaults if you are not careful, was the marshall producucer compiled
with the same version as the marshall user? (I am not sure to be very
clear...) and check the types produced and those used
>
> - 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 its not, Ill 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)
>
I am not shocked by the segfault (I am a lot more by your code), try
rather let l = !myref in List.iter myfun l
>
> - 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 (Im talking about the byterun and the
> asmrun/asmcomp directories), meaning that they dont share any source
> code. Is that correct?
>
> Anyway guys, thanks for reading this, if you did, dont know if this
> makes any sense to you.
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
--
Cédric AUGER
Univ Paris-Sud, Laboratoire LRI, UMR 8623, F-91405, Orsay
next reply other threads:[~2009-08-08 9:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-08 9:17 ivan chollet [this message]
2009-08-08 13:29 ` Edgar Friendly
2009-08-08 14:15 ` ivan chollet
2009-08-08 17:14 ` David Allsopp
2009-08-09 1:45 ` ivan chollet
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='000301ca1809$1658efa0$430acee0$@chollet@free.fr' \
--to=ivan.chollet@free.fr \
--cc=Cedric.Auger@lri.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