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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id E230EBBBB for ; Mon, 13 Mar 2006 16:54:33 +0100 (CET) Received: from electre.pasteur.fr (electre.pasteur.fr [157.99.64.120]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k2DFsXlX011098 for ; Mon, 13 Mar 2006 16:54:33 +0100 Received: from [157.99.164.38] (fennel.sysbio.pasteur.fr [157.99.164.38]) by electre.pasteur.fr (8.12.11/8.12.11) with ESMTP id k2DFsWnT444631 for ; Mon, 13 Mar 2006 16:54:33 +0100 (CET) Message-ID: <441595B8.3040203@crans.org> Date: Mon, 13 Mar 2006 16:54:32 +0100 From: =?ISO-8859-1?Q?=22Sayan_=28S=E9bastien_Li-Thiao-T=E9=29=22?= User-Agent: Debian Thunderbird 1.0.7 (X11/20051019) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Allocating caml lists from C : possible bug on amd64 References: <440F556A.9010209@crans.org> <44158770.6000407@crans.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at nez-perce with ID 441595B9.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; allocating:01 bug:01 markus:01 mottl:01 alloc:01 overwrite:01 alloc:01 compiler:01 compiler:01 stdio:01 mlvalues:01 bigarray:01 val:01 val:01 camlparam:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Markus Mottl wrote: > On 3/13/06, *"Sayan (Sébastien Li-Thiao-Té)"* > wrote: > > I am trying to learn how to allocate a list in C and pass the result to > Caml on an opteron Debian box. Here is the function that I use : > > > Your function does not protect "str" from being reclaimed by the GC > (which can happen in "caml_alloc_small"), and you should use the > Field-macro only to overwrite the contents of the cons-block in this > particular case, because you had used "caml_alloc_small" as allocation > function, and there was no intermediate allocation. > I have already tried to be GC-friendly, and use the "standard" way to do things. For example the following function also works using a 32-bit chroot, but also fails with the 64-bit compiler. The question is : why does it fail with the 64-bit compiler? #include #include #include #include test_liste (value str) { // test function to return a list to caml // value cons; // cons = caml_alloc_small (2,0); // caml_modify(&Field(cons,0),Val_int(0)); // caml_modify(&Field(cons,1),Val_int(0)); CAMLparam1(str); CAMLlocal1(cons); cons = caml_alloc (2,0); Store_field(cons,0, Val_int(1)); Store_field(cons,1, Val_int(0)); printf("This is test_liste.\n"); printf(String_val(str)); fflush(stdout); if (Is_block(cons)) { printf("true\n");}; fflush(stdout); printf("cons has size %i \n",Wosize_val(cons)); fflush(stdout); CAMLreturn (cons); } -- Li-Thiao-Té Sébastien