From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p79MsGt1009368 for ; Wed, 10 Aug 2011 00:54:16 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoMGAHW5QU7Lzuai/2dsb2JhbABCmCePGXeBQAEBBAE6RAsLRj0aiAbACYZGBJs/iEY X-IronPort-AV: E=Sophos;i="4.67,346,1309730400"; d="scan'208";a="105106289" Received: from hendrix.mega-nerd.net ([203.206.230.162]) by mail4-smtp-sop.national.inria.fr with ESMTP; 10 Aug 2011 00:54:00 +0200 Received: from hendrix.mnn (hendrix.mnn [192.168.200.99]) by hendrix.mega-nerd.net (Postfix) with SMTP id 9781A10712A for ; Wed, 10 Aug 2011 08:53:57 +1000 (EST) Date: Wed, 10 Aug 2011 08:53:57 +1000 From: Erik de Castro Lopo To: caml-list@inria.fr Message-Id: <20110810085357.73059efd1f39ef2e9466ccd3@mega-nerd.com> In-Reply-To: <20110809113359.c306a95842c0c86ea160025d@mega-nerd.com> References: <20110808131504.d9137220d4b4401cc3450e5a@mega-nerd.com> <20110808035322.GI29083@localhost> <20110808174619.00b76d12a02f2c58c10c0108@mega-nerd.com> <20110808080356.GD29083@localhost> <4E401BC7.5040001@inria.fr> <20110809113359.c306a95842c0c86ea160025d@mega-nerd.com> Reply-To: caml-list@inria.fr Organization: Erik Conspiracy Secret Labs X-Mailer: Sylpheed 3.2.0beta1 (GTK+ 2.24.4; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Val_int vs caml_copy_nativeint Erik de Castro Lopo wrote: > This is strange, it wasn't declared with a CAMLlocal macro and it > was working, but if I do declare it with one the program segfaults > during garbage collection (caml_oldify_local_roots). Ok, with the help of someone off list I've sorted this out to my satisfaction. Things learned: a) In the C stub function, the call to CAMLParamN must be the first thing in the function, followed by any CAMLlocalN declarations. These should even occur before before any declarations of local C variables. b) caml_copy_nativeint creates a boxed native int (either Int32.t or Int64.t) not an unboxed Ocaml int. To create an unboxed Ocaml int, Val_int() is the correct macro. Thanks to all that responded. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/