caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Anil Madhavapeddy <anil@recoil.org>
To: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Causes for segfaults
Date: Mon, 15 Nov 2010 19:00:00 +0000	[thread overview]
Message-ID: <A0AC0FF3-CF20-4676-8D68-B7DF388ACB8B@recoil.org> (raw)
In-Reply-To: <20101115185016.GC12576@yquem.inria.fr>

On 15 Nov 2010, at 18:50, Daniel de Rauglaudre wrote:

> On Mon, Nov 15, 2010 at 07:38:25PM +0100, Jamie Brandon wrote:
> 
>> jamie@jamie-aspire:~$ cat > segfault.ml
>> let rec ints n = n :: ints (n+1)
>> let _ = ints 0
>> jamie@jamie-aspire:~$ ocamlopt segfault.ml
>> jamie@jamie-aspire:~$ ./a.out
>> Segmentation fault
> 
> Stack overflow in native code triggers a segmentation fault, indeed.
> I think in C, it is the same thing. Not tested in the OCaml runtime
> for efficiency purposes, I think.

The runtime can detect native stack overflow if the OS supports it. See the HAS_STACK_OVERFLOW_DETECTION define in the configure script :

case "$arch,$system" in
  i386,linux_elf|amd64,linux|power,rhapsody|amd64,macosx|i386,macosx|amd64,macosx)
    echo "System stack overflow can be detected."
    echo "#define HAS_STACK_OVERFLOW_DETECTION" >> s.h;;
  *)
    echo "Cannot detect system stack overflow.";;
esac

This works great for me on both MacOS X 10.6 and x86_64 Linux.

avsm@brolga-0:~$ uname -a
Linux brolga-0 2.6.27.29-0.1.1.xs0.1.0.669.1028xen-xcixen #3 SMP Thu Dec 24 23:39:24 GMT 2009 x86_64 GNU/Linux
avsm@click$ uname -a
Darwin click.local 10.5.0 Darwin Kernel Version 10.5.0: Fri Nov  5 23:19:13 PDT 2010; root:xnu-1504.9.17~1/RELEASE_X86_64 x86_64

avsm@brolga-0:~$ cat > segfault.ml
let rec ints n = n :: ints (n+1)
let _ = ints 0
avsm@brolga-0:~$ ocamlopt segfault.ml 
avsm@brolga-0:~$ ./a.out 
Fatal error: exception Stack_overflow

Take a look at your configure script output to see if it isn't being detected I guess. There may also be some interaction with your shell ulimit that forces a SIGSEGV, perhaps.

Anil

  reply	other threads:[~2010-11-15 19:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-04 20:19 Jamie Brandon
2010-11-04 20:25 ` [Caml-list] " Raphael Proust
2010-11-04 20:39   ` Jamie Brandon
2010-11-05 15:54     ` David MENTRE
2010-11-05 22:18     ` oliver
2010-11-04 20:41 ` Till Varoquaux
2010-11-05 23:14   ` Jamie Brandon
     [not found]   ` <384325291.294734.1288998871132.JavaMail.root@zmbs3.inria.fr>
2010-11-06  2:51     ` Daniel de Rauglaudre
2010-11-08 14:26       ` Jamie Brandon
2010-11-08 14:48         ` Till Varoquaux
2010-11-10 15:52           ` Jamie Brandon
2010-11-15 17:58             ` Jamie Brandon
2010-11-15 18:17               ` John Whitington
2010-11-15 18:38                 ` Jamie Brandon
2010-11-15 21:47                   ` Török Edwin
     [not found]                 ` <157788745.568057.1289846305435.JavaMail.root@zmbs3.inria.fr>
2010-11-15 18:50                   ` Daniel de Rauglaudre
2010-11-15 19:00                     ` Anil Madhavapeddy [this message]
2010-11-15 19:08                     ` Norman Hardy
     [not found]                     ` <1795362267.568432.1289847605872.JavaMail.root@zmbs3.inria.fr>
2010-11-15 19:21                       ` Daniel de Rauglaudre

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=A0AC0FF3-CF20-4676-8D68-B7DF388ACB8B@recoil.org \
    --to=anil@recoil.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=daniel.de_rauglaudre@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).