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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id BF82E7FA5C for ; Tue, 21 Jun 2016 14:43:14 +0200 (CEST) IronPort-PHdr: 9a23:+gcL9xEEEvQFi3yQ4KyB/Z1GYnF86YWxBRYc798ds5kLTJ75o8ywAkXT6L1XgUPTWs2DsrQf2rKQ6/irAzVIyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4Ov7yUtaLyZ/mj6bqo9aJOk1hv3mUX/BbFF2OtwLft80b08NJC50a7V/3mEZOYPlc3mhyJFiezF7W78a0+4N/oWwL46pyv50IbaKvdK09SflcDS86G2Ez/szi8xfZHiWV4X5JfH8flJVPAhPyxhbwWYu55iXgv+x23yiBe8fxR7cocT+v5uFlUkm72288Kzcl/TSP2YRLh6VBrUf5qg== Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=francois.bobot@cea.fr; spf=None smtp.mailfrom=francois.bobot@cea.fr; spf=None smtp.helo=postmaster@cirse-out.extra.cea.fr Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of francois.bobot@cea.fr) identity=pra; client-ip=132.167.192.142; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="francois.bobot@cea.fr"; x-sender="francois.bobot@cea.fr"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of francois.bobot@cea.fr) identity=mailfrom; client-ip=132.167.192.142; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="francois.bobot@cea.fr"; x-sender="francois.bobot@cea.fr"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@cirse-out.extra.cea.fr) identity=helo; client-ip=132.167.192.142; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="francois.bobot@cea.fr"; x-sender="postmaster@cirse-out.extra.cea.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DcAQDtNWlXh47Ap4RdhD+7SYF6hhcCgTQ6EgEBAQEBAQEBEQEBAQgNCQkhL4IxghoBAQEDATIBBVELGC5XEwgCiCQIwUsBCwEkiB4Igk6FDIUPBZh5l3KFXY94JQGCNRILF4E3izQBAQE X-IPAS-Result: A0DcAQDtNWlXh47Ap4RdhD+7SYF6hhcCgTQ6EgEBAQEBAQEBEQEBAQgNCQkhL4IxghoBAQEDATIBBVELGC5XEwgCiCQIwUsBCwEkiB4Igk6FDIUPBZh5l3KFXY94JQGCNRILF4E3izQBAQE X-IronPort-AV: E=Sophos;i="5.26,504,1459807200"; d="scan'208";a="181997328" Received: from cirse-out.extra.cea.fr ([132.167.192.142]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 21 Jun 2016 14:43:14 +0200 Received: from pisaure.intra.cea.fr (pisaure.intra.cea.fr [132.166.88.21]) by cirse.extra.cea.fr (8.15.2/8.15.2/CEAnet-Internet-out-2.4) with ESMTP id u5LChDKh017995 for ; Tue, 21 Jun 2016 14:43:13 +0200 Received: from pisaure.intra.cea.fr (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id D4AA620715C for ; Tue, 21 Jun 2016 14:44:02 +0200 (CEST) Received: from muguet2.intra.cea.fr (muguet2.intra.cea.fr [132.166.192.7]) by pisaure.intra.cea.fr (Postfix) with ESMTP id C2F452071D8 for ; Tue, 21 Jun 2016 14:44:02 +0200 (CEST) Received: from [10.8.32.80] (is222783.intra.cea.fr [10.8.32.80]) by muguet2.intra.cea.fr (8.15.2/8.15.2/CEAnet-Intranet-out-1.4) with ESMTP id u5LChDbc031297 for ; Tue, 21 Jun 2016 14:43:13 +0200 To: caml-list@inria.fr References: <7182303B-EBFF-4CFC-A7DF-B5C7A059509F@marneu.com> <3673db34-9350-a9b1-fcd5-e7593ba0fd01@etorok.net> <86eg7ucu8s.fsf@lpw25.net> From: =?UTF-8?Q?Fran=c3=a7ois_Bobot?= Message-ID: <0d64f186-6518-dea7-9082-4c06802449f7@cea.fr> Date: Tue, 21 Jun 2016 14:43:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.0 MIME-Version: 1.0 In-Reply-To: <86eg7ucu8s.fsf@lpw25.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Caml-list] Presumed bug in OCaml's garbage collector or in its Weak module... On 18/06/2016 18:54, Leo White wrote: >> Shallow copies don't seem very safe in the presence of out-of-OCaml-heap C pointers [*]. >> Perhaps Weak.get_copy should raise if it encounters a Custom_tag? > > Shallow copies aren't even type-safe in the proper sense of the word, > since copying a value of abstract type breaks abstraction. This is why > Obj.dup is in the Obj module. Really Weak.get_copy shouldn't exist, or > should at least be part of Obj not Weak. That's interesting, perhaps I should not have given access to get_copy in Ephemeron. > > I suspect Weak.get_copy only really exists for implementing the weak > hash tables, and even there using it means that you could give Weak.Make > a valid argument whose equal function used `==` and it would give > incorrect results. The weak hashtable of ephemerons doesn't use get_copy, specifically because of that. The weak set of Weak are mostly used for hashconsing where the equal function given to Make must not be (==). But for the other use-case, it could be indeed a problem. However it would be interesting to keep the nice property that `get_copy` give us for the implementation of weak structure, without using unsafe features. The nice property is that a value is not kept alive just because it collides with a value that is often accessed. Perhaps a kind of transient roots, which are considered as root only at the end of the each part of mark phase, would allow to mark the value as few time as possible. But the API would not be pretty... -- François