From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id F1566BC57 for ; Mon, 15 Nov 2010 22:47:36 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ak4BAJo54UzRVdY0k2dsb2JhbACiUwgVAQEBAQkJCgkRAx+IJp4/iWCCGIUOLohZAQEDBYVFBI5J X-IronPort-AV: E=Sophos;i="4.59,202,1288566000"; d="scan'208";a="87078254" Received: from mail-bw0-f52.google.com ([209.85.214.52]) by mail1-smtp-roc.national.inria.fr with ESMTP; 15 Nov 2010 22:47:15 +0100 Received: by bwz4 with SMTP id 4so5621911bwz.39 for ; Mon, 15 Nov 2010 13:47:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type:content-transfer-encoding; bh=hNaf9H4nin35U7dppSiISRMgfM2NMRS2p0KBc2R+Fkc=; b=vSAXHWvxxKH9iHQH6Ztkj+hYoyJxUdPQAiocPuzxPKesjT+14qr0lK41S8G1yhf0rf thjOeLduhUmN8aRkNZ6ZRiKHOxVKDL//vQfnOMRXhnOG3M0Z37gWoQaBjRid9rPMkQlz HQhZ/9XuUoJCnRfqzMWa9mk55wgxcZLYMDcXo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=Gs7UhjzH19G6J15roalPoybHhp7bn3+WHLscZEjK9RmVZfUQdsHej7N8bxrdO7dB9W UqOssBQtPK5erkVuIX9jfv/IB/Kqy80gNqxpulhlxpz5J1R73dIgQWcxO0eIX1uvC1ks ow2bUczhehg/WVTqe+zYtRz63Au/nY8/MzsBU= Received: by 10.204.103.66 with SMTP id j2mr6498833bko.160.1289857635447; Mon, 15 Nov 2010 13:47:15 -0800 (PST) Received: from deb0 ([79.114.58.70]) by mx.google.com with ESMTPS id a25sm248031bks.20.2010.11.15.13.47.14 (version=SSLv3 cipher=RC4-MD5); Mon, 15 Nov 2010 13:47:15 -0800 (PST) Date: Mon, 15 Nov 2010 23:47:12 +0200 From: =?UTF-8?B?VMO2csO2aw==?= Edwin To: Jamie Brandon Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Causes for segfaults Message-ID: <20101115234712.16bc8f34@deb0> In-Reply-To: References: <384325291.294734.1288998871132.JavaMail.root@zmbs3.inria.fr> <20101106025118.GA23041@yquem.inria.fr> <4CE1792B.3050603@coherentgraphics.co.uk> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; segfaults:01 recursion:01 uname:01 ocaml:01 -version:01 toplevel:01 segfault:01 ocamlopt:01 segfault:01 recursion:01 ocaml:01 runtime:01 edwin:98 brandon:98 53.:98 On Mon, 15 Nov 2010 18:38:18 +0000 Jamie Brandon wrote: > > Excessive recursion of a function does raise an exception, on most > > platforms, doesn't it? > > [root@senldogo0183 texsearch-development2]# uname -a > Linux senldogo0183 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:19 EDT 2007 > x86_64 x86_64 x86_64 GNU/Linux > [root@senldogo0183 texsearch-development2]# ocaml -version > The Objective Caml toplevel, version 3.12.0 > [root@senldogo0183 texsearch-development2]# cat > segfault.ml > let rec ints n = n :: ints (n+1) > let _ = ints 0 > [root@senldogo0183 texsearch-development2]# ocamlopt segfault.ml > [root@senldogo0183 texsearch-development2]# ./a.out > Segmentation fault I get a proper exception: Fatal error: exception Stack_overflow Linux debian 2.6.36-phenom #107 SMP PREEMPT Sat Oct 23 10:30:01 EEST 2010 x86_64 GNU/Linux Although you have to be careful with recursion and calls to C code, calling the C code may be the one overflowing the stack, and the ocaml runtime doesn't generate stack overflow exception for that (only for OCaml code). You will probably need the patch from http://caml.inria.fr/mantis/view.php?id=5064 for that. Best regards, --Edwin