From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 2144D7FEEB for ; Sat, 18 Jun 2016 12:59:45 +0200 (CEST) IronPort-PHdr: 9a23:FgqEwB+3YJKXCf9uRHKM819IXTAuvvDOBiVQ1KB80u8cTK2v8tzYMVDF4r011RmSDdSduqgP0baempujcFJDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXsq3G/pQQfBg/4fVIsYL+lS8iD1Y/ti6ibwN76XUZhvHKFe7R8LRG7/036l/I9ps9cEJs30QbDuXBSeu5blitCLFOXmAvgtI/rpMYwuwwZgf8q9tZBXKPmZOx4COUAVHV1e1wysejirwXCSzy1oEw6X3gWHgf/DhKNuAn9RYvZtyLgsOdgniKdOJuyBYyqQ6qhp4pnVx7uwHMKOyE49iLSjol3h6tepDqsuxtlxI2SZoyJYqlQZKTYKPEdXmoJdMtLWy1HD8vobYwUD8ILMPxUro/w4V0DsU3tVkGXGOrzx2oQ1TfN1qog3rFkSFme0Q== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=josh@berdine.net; spf=Pass smtp.mailfrom=josh@berdine.net; spf=None smtp.helo=postmaster@out3-smtp.messagingengine.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of josh@berdine.net) identity=pra; client-ip=66.111.4.27; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="josh@berdine.net"; x-sender="josh@berdine.net"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of josh@berdine.net designates 66.111.4.27 as permitted sender) identity=mailfrom; client-ip=66.111.4.27; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="josh@berdine.net"; x-sender="josh@berdine.net"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@out3-smtp.messagingengine.com) identity=helo; client-ip=66.111.4.27; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="josh@berdine.net"; x-sender="postmaster@out3-smtp.messagingengine.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0A2AQAJKWVXhxsEb0JdhRGCfrlghhcCgSE7EQEBAQEBAQEBEQEBAQoLCQkhL4IxghsBAQMBDBcdOQEECwkCGgIFIQICDwEcKwYBiDoIkl2dHYRJi2ABAQEHAQEBAQEBARgIgQGJc4RAgwGCWph7jxCIT4Vtj3c0gicSCxeBNm2KSAEBAQ X-IPAS-Result: A0A2AQAJKWVXhxsEb0JdhRGCfrlghhcCgSE7EQEBAQEBAQEBEQEBAQoLCQkhL4IxghsBAQMBDBcdOQEECwkCGgIFIQICDwEcKwYBiDoIkl2dHYRJi2ABAQEHAQEBAQEBARgIgQGJc4RAgwGCWph7jxCIT4Vtj3c0gicSCxeBNm2KSAEBAQ X-IronPort-AV: E=Sophos;i="5.26,487,1459807200"; d="scan'208";a="222949579" Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jun 2016 12:59:44 +0200 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id BF8772061D; Sat, 18 Jun 2016 06:59:42 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Sat, 18 Jun 2016 06:59:42 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=berdine.net; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=B09cvDLFZF2yg7JkEc7Vfj8EPTg=; b=su7vv2 U9OE2ydfmZhz5x1XBqiVJ1vK0fRBMjSS2T0Pyb16rpYIL0DkPEOTze7hi+mTVLtG reSiolWzGPPvjJ1AHNQ2+6QvTYHHv/E+NNm9ZvYppbqa1LJS5c33vpfRflsgkLoJ JFbO5Z5HdIitVsXSJMhlX33B8sK8xjUQsUznM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=B09cvDLFZF2yg7J kEc7Vfj8EPTg=; b=WemVQMp13WDg6plRZWsQazgxEK3WANd9Rx/dGuqxhev5sge Mr2cPwjS1iMP1jGnMVxqk5KiYCrbrIDC6HpgiYOtWLOL1tFzhZ2vC5yu8KfoaPdP v/3S4DGwiGarP8fW0+P131EjipLDTRH9nO7iSy9H9nc8G0QHDQW4nXKbwd0w= X-Sasl-enc: u1ceHunq84IuPJpjWsuUjW9++SxINmoWtwp+UhRG0jJw 1466247582 Received: from jjb-mbp.localdomain (unknown [199.201.66.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 570B2F29F4; Sat, 18 Jun 2016 06:59:42 -0400 (EDT) Received: by jjb-mbp.localdomain (Postfix, from userid 994052071) id 280584357382; Sat, 18 Jun 2016 11:59:40 +0100 (BST) From: Josh Berdine To: =?utf-8?Q?Martin_R=2E_Neuh=C3=A4u=C3=9Fer?= , =?utf-8?B?VMO2csO2aw==?= Edwin Cc: caml-list@inria.fr In-Reply-To: <01CFEDAE-C1CB-4968-9FDF-1EC004CC027A@marneu.com> References: <7182303B-EBFF-4CFC-A7DF-B5C7A059509F@marneu.com> <3673db34-9350-a9b1-fcd5-e7593ba0fd01@etorok.net> <01CFEDAE-C1CB-4968-9FDF-1EC004CC027A@marneu.com> Date: Sat, 18 Jun 2016 11:59:40 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Presumed bug in OCaml's garbage collector or in its Weak module... On Fri, Jun 17 2016, Martin R. Neuh=C3=A4u=C3=9Fer wrote: > Thanks for the good point! And yes, the weak sets use Weak.get_copy inter= nally. I have also run into this when writing C bindings for a library with ref-co= unted memory management, where the OCaml finalizers decremented the C count= s. Since the functions in the structure passed to Weak.Make can be passed = shallow copies of possibly-dead values, these functions need to be prepared= for the underlying C values to have already been finalized. That's tough = to deal with. (I ended up just letting Z3 hash-cons it's own terms, and ke= pt pointers into Z3 out of my own hash-consed terms.) > However, the exact semantics of Weak.get_copy is still a bit unclear to m= e. It creates a =E2=80=9Eshallow copy=E2=80=9C of a value that might indepe= ndently be garbage collected. If that shallow copy can survive the finaliza= tion of its source, that might cause the problem. Are there any restriction= s enforced on values obtained by Weak.get_copy? Or could this even be misus= ed to create arbitrary copies of custom blocks that propagate anywhere? If the functions passed to Weak.Make store the shallow copy into some globa= l state, it seems that they could live on without constraint. Cheers, Josh