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=AWL autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 3756BBBC1 for ; Thu, 10 Apr 2008 19:48:13 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlkBADfv/UdQRFuwiGdsb2JhbACRTQEBAQ8mmWc X-IronPort-AV: E=Sophos;i="4.25,636,1199660400"; d="scan'208";a="9441521" Received: from furbychan.cocan.org ([80.68.91.176]) by mail2-smtp-roc.national.inria.fr with ESMTP; 10 Apr 2008 19:48:13 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1Jk0sc-0004G5-37; Thu, 10 Apr 2008 18:48:10 +0100 Date: Thu, 10 Apr 2008 18:48:10 +0100 To: Raj Bandyopadhyay Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Question about CAMLparamx macros Message-ID: <20080410174809.GA16258@annexia.org> References: <47FE3E65.7030907@rice.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47FE3E65.7030907@rice.edu> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Spam: no; 0.00; segfaults:01 ocaml:01 oldify:01 camlparam:01 camlreturn:01 ocaml:01 pointers:01 10,:98 wrote:01 caml-list:01 macros:01 macros:01 defined:02 roots:02 programming:03 On Thu, Apr 10, 2008 at 11:20:53AM -0500, Raj Bandyopadhyay wrote: > I am programming using the OCaml-C interface, and occasionally, my > program segfaults in the OCaml function 'caml_oldify_local_roots()' > > From previous experience, I know that this usually means that I'm not > using the CAMLparam/CAMLreturn macros correctly somewhere, causing the > OCaml gc to find NULL pointers. > > My question is, when do I have to use or not use these macros? I know I > need to use these when my C function accepts AND returns OCaml 'value' > types, but what about the following cases? It's very instructive to actually look at how these macros are defined (ie. what code they expand to). There's nothing particularly magical or complicated about them. Rich. -- Richard Jones Red Hat