On 15 Nov 2010, at 18:50, Daniel de Rauglaudre wrote: > On Mon, Nov 15, 2010 at 07:38:25PM +0100, Jamie Brandon wrote: > >> ja...@jamie-aspire:~$ cat > segfault.ml >> let rec ints n = n :: ints (n+1) >> let _ = ints 0 >> ja...@jamie-aspire:~$ ocamlopt segfault.ml >> ja...@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. a...@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 a...@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 a...@brolga-0:~$ cat > segfault.ml let rec ints n = n :: ints (n+1) let _ = ints 0 a...@brolga-0:~$ ocamlopt segfault.ml a...@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 _______________________________________________ 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