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 ADB1CBC37 for ; Sat, 8 Aug 2009 23:15:00 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnQDAO+HfUpQW+UCe2dsb2JhbACaSgEBFiQEs2KEFwU X-IronPort-AV: E=Sophos;i="4.43,347,1246831200"; d="scan'208";a="34186345" 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 23:15:00 +0200 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MZtFh-0001lJ-GU for caml-list@inria.fr; Sat, 08 Aug 2009 21:14:57 +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 21:14:57 +0000 Received: from sylvain by ks300734.kimsufi.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 08 Aug 2009 21:14:57 +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 21:14:45 +0000 (UTC) Message-ID: References: <23185.6251172305$1249751407@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 ocaml:01 advices:01 runtime:01 runtime:01 ocamlrun:01 gdb:01 ocamlrun:01 iter:01 iter:01 myfun:01 myfun:01 pointers:01 On 08-08-2009, ivan chollet wrote: > > Yes it was a freebsd 6.4 with ocaml 3.10.2 > OCaml version is quite old, but should be ok. > I'll run the program on linux later and see how it goes. > > > > Thanks for your advices regarding debugging. I pretty much tried all of > these though. the thing is my error is not an ocaml error at runtime but an > error of the ocaml runtime. And to analyze a core dump of ocamlrun, I just > thought my best bet was gdb. Whatever. > > > > OK I'll try to provide you with a minimal ocaml code that produce an > ocamlrun error. Might take a little while as I'm not free. > > In the meantime, I've got a newbie question regarding ocaml garbage > collector and the same List.iter stuff: > > Say you do a "List.iter myfun !myref", where !myref is a list (hehe.), and > where myfun is a function that does reallocations of myref (that is > affectations like myref := [some new or old objects]). The pointers myref > that are generated through this process are destroyed each time a new > reallocation of myref is done. Of course the underlying linked lists that > are not referenced anymore shouldn't be collected by the GC before the end > of the main "List.iter", otherwise it's iterating through a linked list that > has been garbage collected. > > My question is: does the GC know that it cannot collect the unreferenced > myref pointers before the end of the List.iter? > Why "the underlying linked lists that not referenced anymore shouldn't be collected by the GC before the end the main "List.iter"" ? OCaml list are single-linked list, whenever you cannot access the head of the list everything until the current element can be GCed. Here is the implementation of List.iter let rec iter f = function [] -> () | a::l -> f a; iter f l As soon as you apply "myfun" to "a", the reference to a is not used so it can be collected by the GC if there is no more reference to it. I think the GC CAN collect the unreferenced myref pointers before the end of the List.iter... Regards Sylvain Le Gall