From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_FAIL autolearn=disabled version=3.1.3 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 61709BC37 for ; Sat, 8 Aug 2009 11:38:11 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnQDAN7jfEpQW+UCe2dsb2JhbACaSgEBFiQEtAqEFwU X-IronPort-AV: E=Sophos;i="4.43,345,1246831200"; d="scan'208";a="34172270" Received: from main.gmane.org (HELO ciao.gmane.org) ([80.91.229.2]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 08 Aug 2009 11:38:10 +0200 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MZiNH-0007ev-UK for caml-list@inria.fr; Sat, 08 Aug 2009 09:38:03 +0000 Received: from ks300734.kimsufi.com ([91.121.65.225]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 08 Aug 2009 09:38:03 +0000 Received: from sylvain by ks300734.kimsufi.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 08 Aug 2009 09:38:03 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Sylvain Le Gall Subject: Re: ocaml sefault in bytecode: unanswered questions Date: Sat, 8 Aug 2009 09:37:54 +0000 (UTC) Message-ID: References: <16043.1656208404$1249662628@news.gmane.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ks300734.kimsufi.com User-Agent: slrn/pre1.0.0-2 (Linux) Sender: news X-Spam: no; 0.00; le-gall:01 ocaml:01 bytecode:01 gdb:01 ocaml:01 bytecode:01 gdb:01 runtime:01 ocamldebug:01 backtrace:01 gcc:01 backtrace:01 runtime:01 segfaults:01 segfault:01 On 07-08-2009, ivan chollet wrote: > > This GDB was configured as "i386-marcel-freebsd"...(no debugging symbols > found)... > > Not very informative. So here are my questions: I suppose you are running freebsd ? Which version of freebsd, of ocaml ? > > > > - 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? > gdb is not the perfect tool to debug ocaml program. You should give a try to ocamldebug which is a better option for bytecode (see below for options). Bytecode is more informative when coming to reporting backtrace (at least with old version of ocaml). Compile every program with "-g" option (just like gcc). If you have compiled everything with "-g" option, you can also use the environment variable OCAMLRUNPARAM="b" to get a backtrace for your exception, at runtime. > - 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? Some part of the bytecode are just standard C, everything can cause a segfault just as C. These errors are not very common but it is possible that some case are not well handled on freebsd. Most probably a porting issue. Marshal module can easily trigger a segfault when you map the loaded data to a type which doesn't match the dumped data. Example: List.length (Marshal.from_string (Marshal.to_string 1234 []) 0);; Here the integer value is marshalled and then unmarshalled as a list -> segfault. > > - 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 it's not, I'll 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) > Could you provide a minimal example code for this error ? I don't think this should generate a segfault. Regards Sylvain Le Gall