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=2.0 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL 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 ED76DBBAF for ; Fri, 8 May 2009 15:48:22 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApwBACvVA0rRVdqykGdsb2JhbACDAJNPPwEBAQEJCQwHEQOnOIERkBQBAwEDg3oF X-IronPort-AV: E=Sophos;i="4.40,317,1238968800"; d="scan'208";a="25828596" Received: from mail-bw0-f178.google.com ([209.85.218.178]) by mail2-smtp-roc.national.inria.fr with ESMTP; 08 May 2009 15:48:22 +0200 Received: by bwz26 with SMTP id 26so1940637bwz.27 for ; Fri, 08 May 2009 06:48:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=8sZ7q4PvsqmMGwP5EY/Gi/UZde4b4TgruRUX9hTkpWc=; b=uNcM31yAKyE0VqOfoOnDTpORBaI+jbV6zGndIh1XBq1bplSBCtbxu9pDhAJeaIMHNZ fo5ZEjqx9js/PJ8Y7APwpg+7McVs0is++2f039wtLxgJKjmam3uuZ49IptQgGcPLpQXR 7YMiaA/TtA55iNGluW/FWZDFXZpXgTr3MFduM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=GqUjegNTsu7EiUOYGubAvAr7kRxe/z7c/Qh9KdCWYy/alseVrbmL2gyUqIm0Nm6zUV sREssbDwB4LeK6OGjaH06p3vfHVKStqyCcvNFzNdQiDDVb3tOnTMkqk04Y5qLfOZQ9r/ 84eLk6YMK9spgFRlnqM89Nso2zx+mSHsgS++M= MIME-Version: 1.0 Received: by 10.204.63.20 with SMTP id z20mr3594015bkh.200.1241790501798; Fri, 08 May 2009 06:48:21 -0700 (PDT) In-Reply-To: <4A03FD30.6020307@inria.fr> References: <49FB04A9.3090008@soton.ac.uk> <4A01BB13.1040602@soton.ac.uk> <4A03FD30.6020307@inria.fr> Date: Fri, 8 May 2009 09:48:21 -0400 Message-ID: Subject: Re: [Caml-list] Custom blocks and finalization From: Markus Mottl To: Xavier Leroy Cc: OCaml List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; markus:01 mottl:01 markus:01 mottl:01 finalizer:01 allocating:01 finalizer:01 camlparam:01 allocations:01 ocaml:01 2009:98 foresee:98 wrote:01 exception:01 heap:01 On Fri, May 8, 2009 at 05:36, Xavier Leroy wrote: > I foresee absolutely no problems with registering/unregistering global > roots from a C finalizer. =A0As the manual states, the big no-no in > C functions attached to custom blocks is allocating in the heap, > either directly or via a callback into Caml or by releasing the global > lock. =A0Within a finalizer, you should also refrain from raising an > exception, as this would leave the GC is a bizarre state. =A0But global > roots operations are OK. Thanks, good to know. I had only taken a superficial look at the implementation and didn't see any problem with global roots, but even if this might be true now, I wasn't sure whether this would remain so in the future. > As for not using the CAMLparam, etc macros in these functions: since > these functions must not allocate, the macros are certainly not > needed. =A0I don't think that actually using them could cause a problem, > but that would be silly anyway, so don't use them in this context. Right, since allocations are prohibited anyway, one doesn't need to protect the passed value and won't need local roots. I guess the documentation could still be clarified in this respect, because the explicit prohibition of using the local root (de)registration functions suggests that these operations are not guaranteed to be sound and that this might also extend to global roots. Regards, Markus --=20 Markus Mottl http://www.ocaml.info markus.mottl@gmail.com