From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p4FDpWCO024795 for ; Sun, 15 May 2011 15:51:32 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtUBAMLYz01KfVK2kGdsb2JhbACmDQgUAQEBAQkJDQcUBCGqOIJCjBqCNYNlN4hiAQEDBoYTBJARhC+BEYVFO4M3 X-IronPort-AV: E=Sophos;i="4.64,369,1301868000"; d="scan'208";a="108598910" Received: from mail-wy0-f182.google.com ([74.125.82.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 15 May 2011 15:51:27 +0200 Received: by wyf23 with SMTP id 23so5213930wyf.27 for ; Sun, 15 May 2011 06:50:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:content-type:content-transfer-encoding :subject:date:message-id:to:mime-version:x-mailer; bh=lmbgSqDxSLs7Kj2WIokPOew/LTasmqQhlcLtnJMli0Y=; b=teMtRT51Whr4E+T6Mkwh2Jrj8yH4aNlAX0En90610nw9aw6+uPaVNQcmyCCfR0hp0W mRhPQhM6Mkeqcq0RXl0dCmKcbZKy1SAMWso6pr2mwh/4oa0mwK7RjyIOr2QZT3t8WPQu BkbfKoo/wlR9kZBSgZLFCobxXC886pan73xOA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; b=rvd8+xncGzapjRqC35oLbYXihHfAH976SubRtvb2X59pk/9a1gjU5hGOotPt7VaNhj r5FzOAI1M8+G+0dfZbBzV1+2664mXJcMzga2XVObYkCoLihxFNG17R//uvdcmTobNeQQ y1zCJbJ8jdPuTXk+Wc72kEBvMqHX4QUS2fQLw= Received: by 10.216.15.137 with SMTP id f9mr3223905wef.62.1305467437395; Sun, 15 May 2011 06:50:37 -0700 (PDT) Received: from [172.16.13.82] (0xc2efec01.hotspot.tele.dk [194.239.236.1]) by mx.google.com with ESMTPS id k63sm2069875wed.47.2011.05.15.06.50.35 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 15 May 2011 06:50:36 -0700 (PDT) From: Joel Reymont Content-Type: text/plain; charset=us-ascii Date: Sun, 15 May 2011 15:50:34 +0200 Message-Id: <88F79E1B-2D9F-4A17-A6B7-060074FF77E9@gmail.com> To: caml-list Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p4FDpWCO024795 Subject: [Caml-list] problem with array access in a c function The types are at the bottom here, in the Poll module: https://github.com/wagerlabs/ocaml-zmq/blob/master/src/ZMQ.ml The C function in question is caml_zmq_poll_of_pollitem_array here: https://github.com/wagerlabs/ocaml-zmq/blob/master/src/poll.c I can grab the number of elements in the array just fine, e.g. int n = Wosize_val(pollitem_array); This will give me n of 1 or 2, depending on the number of tuples in the array. This sets current_elem to 0x400 (1024) current_elem = Field(pollitem_array, n); This returns 1 int block = Is_block(current_elem); And this crashes int tag = Tag_val(current_elem); Subsequent attempts to pull out the custom data crash as well. Interestingly enough, Field(current_value, 0) and Field(current_value, 1) are 8 bytes apart. I'm on a 64-bit machine and I expect tuple elements to be pointers since one is a custom block and the other a variant. What am I doing wrong? Thanks, Joel -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+---------------------------------------