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.4 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 09C87BC69 for ; Thu, 8 Feb 2007 01:16:53 +0100 (CET) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.233]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l180GpVx003240 for ; Thu, 8 Feb 2007 01:16:52 +0100 Received: by wr-out-0506.google.com with SMTP id i22so366140wra for ; Wed, 07 Feb 2007 16:16:51 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=K5/Exow6Z2kSGbKT3QtC3iEgYs9Uuh63RgaLin3VEUbinQJPOjMZ/jcf4vhxQwnYzZ9oZX00Eiimx8j4NOlZKD0C4UFgB6jTgB73EHe9iFrykjzCAnrneb/Cw2Q1Va12hc2msvdyz89XnfvtcqtzXj3vvkwvPoLXXc6zFAH8eAY= Received: by 10.114.110.1 with SMTP id i1mr1699966wac.1170893809524; Wed, 07 Feb 2007 16:16:49 -0800 (PST) Received: from ?192.168.0.3? ( [70.19.37.74]) by mx.google.com with ESMTP id g9sm4555290wra.2007.02.07.16.16.45; Wed, 07 Feb 2007 16:16:47 -0800 (PST) In-Reply-To: <45CA59CA.7030809@rftp.com> References: <5F3F8FC7-2C10-4F4A-A7D3-6268AD6D1E5A@gmail.com> <45CA59CA.7030809@rftp.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <320AFD70-08FF-4F6F-8C1A-E6D5A38B18B7@gmail.com> Cc: Caml-list Content-Transfer-Encoding: 7bit From: Andres Varon Subject: Re: [Caml-list] marshal and C structures crash Date: Wed, 7 Feb 2007 19:16:28 -0500 To: Robert Roessler X-Mailer: Apple Mail (2.752.2) X-j-chkmail-Score: MSGID : 45CA6BF3.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45CA6BF3.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml:01 3.08.4:01 unmarshaling:01 marshaling:01 malloc:01 pointer:01 afaik:01 pointer:01 pointers:01 beginner's:01 bug:01 2007,:98 crystal:98 heap:01 On Feb 7, 2007, at 5:59 PM, Robert Roessler wrote: > Andres Varon wrote: >> ... >> For those of you who reached this line of my email, thanks for the >> effort! I will listen at any ideas that could pop up in your minds. > > Hey, I will read the full message just to see what someone is doing > with 70K lines of OCaml code! :) > jejeje, we detect very complex combinatorial events in DNA sequences, using different optimality criteria, over an evolutionary tree that we are searching for. The program was in version 3 and became painful to maintain (8 years of many hands working on it and - most important -, learning OCaml on it), so now it has been rewritten from scratch. > The usual comment - you don't mention any version and platform > details... especially with something that took as long as this > probably did, those might be of interest (particularly since some > teams doing a project of this size might have not been keeping up > with OCaml releases). > I realized that afterwards! In part I didn't mention it because it's happening consistently in all versions of OCaml and platforms that are applicable to: 3.08.4 and 3.09.2, 3.09.3 running in the following platforms: Mac OS X - PPC / Intel, Linux x86, Linux AMD64, Linux EMT-64. I truly believe it is something I do wrong in my C side, but for the life of mine, I don't see what it is, and I don't understand why it shows up only in relation to successive marshals. Note that the marshalled structure do not include any of my C types wrapped in an OCaml abstract one. It did at the beginning (that was my first suspect), but before working around representations in pure ocaml to try to get rid of the problem, I even compared the output of separate marshals of the same values multiple times, unmarshaling and marshaling again, and comparing different repetitions, with no errors detected. > It is not crystal clear that you are using "finalize" routines - if > so, they are an obvious (and easy) place to position check code. > If not, why not? It sounds like you might *need* to wrap some of > your values created in C-land in smart-but-thin OCaml objects, if > for nothing else than to more delicately handle lifetime issues. > > These "popped up" for me on my initial reading. ;) We malloc the C structures, and store the pointer to them in a custom type for which we provide the functions in OCaml. The registration of the custom type (using a custom_operations structure), includes a free function to deallocate whatever C allocated memory should be when the garbage collector does its job, and we provide them. AFAIK, having a pointer to an allocated C structure wrapped in a custom type is safe, provided the C structure does not point back to the OCaml heap, and we don't: the pointers go in only one direction to the C side. > > Robert Roessler > roessler@rftp.com > http://www.rftp.com > > Thanks! Andres > _______________________________________________ > 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