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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 7BDFEBBBB for ; Mon, 13 Mar 2006 19:05:08 +0100 (CET) Received: from rouge.crans.org (rouge.crans.org [138.231.136.3]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k2DI589c027932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 13 Mar 2006 19:05:08 +0100 Received: from localhost (rouge.adm.crans.org [138.231.144.3]) by rouge.crans.org (Postfix) with ESMTP id D1D81BB92 for ; Mon, 13 Mar 2006 19:05:07 +0100 (CET) Received: from rouge.crans.org ([138.231.144.3]) by localhost (rouge [138.231.144.3]) (amavisd-new, port 10024) with LMTP id 02863-01-96 for ; Mon, 13 Mar 2006 19:05:07 +0100 (CET) Received: from [138.231.150.106] (sayan-ftp.wifi.crans.org [138.231.150.106]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by rouge.crans.org (Postfix) with ESMTP id 02D28BB72 for ; Mon, 13 Mar 2006 19:05:05 +0100 (CET) Message-ID: <4415B45C.5040302@crans.org> Date: Mon, 13 Mar 2006 19:05:16 +0100 From: =?ISO-8859-1?Q?Li-Thiao-T=E9_S=E9bastien?= User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) 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> <441595B8.3040203@crans.org> <4415AF18.5070404@inria.fr> In-Reply-To: <4415AF18.5070404@inria.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at crans.org X-Miltered: at concorde with ID 4415B454.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; allocating:01 bug:01 compiler:01 compiler:01 gcc:01 -wall:01 stdio:01 mlvalues:01 bigarray:01 alloc:01 val:01 val:01 camlparam:01 alloc:01 printf: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 Xavier Leroy wrote: >>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? > > Because your C code is wrong. gcc -Wall is your friend. > >>#include >>#include >>#include >>#include >> >>test_liste (value str) { > > Should be "value test_list(value str)". > Indeed, but my previous mail to this list read "value test_liste (value str)". No problem noticed without it. >> // 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); > > You haven't declared caml_alloc (include ), so the C > compiler assumes it returns an int instead of a value, and generates > wrong code. > That was the main problem. >> Store_field(cons,0, Val_int(1)); >> Store_field(cons,1, Val_int(0)); >> >> printf("This is test_liste.\n"); >> printf(String_val(str)); > > Should be: printf("%s", String_val(str)); > > (Hint: what happens if str contains "%s" ?) > Well, that one was rather a non-production-ready test anyway. I was blocked before even reaching that point. Thanks very much for the help and the -Wall flag. I should have known :) -- Li-Thiao-Té Sébastien