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 B364FBBBB for ; Mon, 13 Mar 2006 15:53:36 +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 k2DErab1003139 for ; Mon, 13 Mar 2006 15:53:36 +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 k2DEraWn422426 for ; Mon, 13 Mar 2006 15:53:36 +0100 (CET) Message-ID: <44158770.6000407@crans.org> Date: Mon, 13 Mar 2006 15:53:36 +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: Allocating caml lists from C : possible bug on amd64 References: <440F556A.9010209@crans.org> In-Reply-To: <440F556A.9010209@crans.org> Content-Type: multipart/mixed; boundary="------------080209000005030600050905" X-Miltered: at nez-perce with ID 44158770.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; allocating:01 bug:01 stdio:01 mlvalues:01 bigarray:01 alloc:01 val:01 val:01 printf:01 printf:01 fflush:01 stdout:01 fflush:01 stdout:01 wosize:01 X-Attachments: name="Makefile" name="Makefile" type="text/x-csrc" name="readPeaks.c" name="readPeaks.c" name="test_liste.ml" name="test_liste.ml" 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 This is a multi-part message in MIME format. --------------080209000005030600050905 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Hi list, 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 : #include #include #include #include value 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)); 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); return (cons); } I call it from (test_liste.ml) : external test_liste : string -> int list = "test_liste";; test_liste "oaue";; Makefile : gcc -c -I/usr/lib64/ocaml readPeaks.c ocamlc -custom readPeaks.o test_liste.ml -o a.out The a.out file is compiled without problems but it crashes with a segfault. However, if I compile on the same machine in a 32-bit chroot, the program works. Can anyone reproduce this behavior? Is that a bug linked to the 64bit implementation of Ocaml or is it a gcc bug? -- Li-Thiao-Té Sébastien --------------080209000005030600050905 Content-Type: text/plain; name="Makefile" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Makefile" OUTPUT = a.out all : top echo "Make finished." clean : rm *.cm* *.o $(OUTPUT) top : gcc -c -I/usr/lib64/ocaml readPeaks.c ocamlc -custom readPeaks.o test_liste.ml -o $(OUTPUT) --------------080209000005030600050905 Content-Type: text/x-csrc; name="readPeaks.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="readPeaks.c" #include #include #include #include value 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)); 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); return (cons); } --------------080209000005030600050905 Content-Type: text/plain; name="test_liste.ml" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="test_liste.ml" external test_liste : string -> int list = "test_liste";; test_liste "oaue";; --------------080209000005030600050905--