Browse thread
Causes for segfaults
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2010-11-15 (19:00) |
From: | Anil Madhavapeddy <anil@r...> |
Subject: | Re: [Caml-list] Causes for segfaults |
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