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=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 67CF6BBC4 for ; Thu, 19 Feb 2009 18:18:23 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao0CABojnUnD2MUqgWdsb2JhbACUVQEBFiK+DYQOBg X-IronPort-AV: E=Sophos;i="4.38,236,1233529200"; d="scan'208";a="23240848" Received: from bluelynx4.ukhost4u.com ([195.216.197.42]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 19 Feb 2009 18:18:23 +0100 Received: from [78.105.203.81] (helo=feast.lan) by bluelynx4.ukhost4u.com with esmtpa (Exim 4.69) (envelope-from ) id 1LaCXV-0003Xb-JE for caml-list@yquem.inria.fr; Thu, 19 Feb 2009 17:18:22 +0000 Message-Id: <15903958-833F-4698-94AB-DF517CBBCEF2@coherentgraphics.co.uk> From: John Whitington To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Debugging a C / Ocaml interface problem Date: Thu, 19 Feb 2009 17:18:19 +0000 X-Mailer: Apple Mail (2.930.3) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bluelynx4.ukhost4u.com X-AntiAbuse: Original Domain - yquem.inria.fr X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - coherentgraphics.co.uk X-Source: X-Source-Args: X-Source-Dir: X-Spam: no; 0.00; ocaml:01 interfacing:01 ocaml:01 bug:01 argv:01 val:01 val:01 camlparam:01 alloc:01 bigarray:01 dims:01 bigarray:01 camlreturn:01 elt:01 constructors:01 Hi Folks, I'm interfacing our Ocaml PDF stuff to C (threads passim), so main programs in C can use the tools. Here's a bug which I can't track down. A value somewhere in the (pure) caml code is changing from one type constructor to another, breaking the code. So some tag in a block is being trampled on? I've gone through all the rules in the manual, and can't find anything wrong. The minimal broken main C program: caml_startup(argv); int hello3 = fromFile("hello.pdf"); removeAttachedFiles(hello3); char data[] = {1,2,3,4,5,6,7,8,9,0}; setMetadataFromByteArray(hello3, data, 10); Here are those functions: int fromFile(char* filename) { return(Int_val(caml_callback(*caml_named_value("fromFile"), caml_copy_string(filename)))); } void removeAttachedFiles(int pdf) { caml_callback(*caml_named_value("removeAttachedFiles"), Val_int(pdf)); return; } void setMetadataFromByteArray(int pdf, char* data, int len) { CAMLparam0 (); CAMLlocal1 (bytestream); bytestream = alloc_bigarray_dims(BIGARRAY_UINT8 | BIGARRAY_C_LAYOUT, 1, data, len); caml_callback2(*caml_named_value("setMetadataFromByteArray"), Val_int(pdf), bytestream); CAMLreturn0; } And here are the types of the caml functions called by those C functions: val fromFile : string -> int val removeAttachedFiles : int -> unit val setMetadataFromByteArray : int -> (int, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> unit All the functions work ok in other circumstances (i.e not in this combination). The failure occurs inside the Caml function setMetadataFromByteArray - Pdf.Indirect 27 is changing to Pdf.Integer 27 (Pdf.Indirect and Pdf.Integer are two constructors of the same type). Can anyone spot anything wrong in the above? Something Bigarray- related perhaps? Any suggestions as to how I might go about further debugging this? With Thanks, -- John Whitington Coherent Graphics Ltd http://www.coherentpdf.com/