From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTPS id 6FA195D4 for ; Thu, 20 Dec 2018 17:41:16 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.56,378,1539640800"; d="scan'208,217";a="361297170" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 20 Dec 2018 18:41:15 +0100 Received: by sympa.inria.fr (Postfix, from userid 20132) id 1C47882567; Thu, 20 Dec 2018 18:41:15 +0100 (CET) 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 F260D824CF for ; Thu, 20 Dec 2018 18:41:08 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=lindsay.errington@gmail.com; spf=Pass smtp.mailfrom=lindsay.errington@gmail.com; spf=None smtp.helo=postmaster@mail-yw1-f52.google.com IronPort-PHdr: =?us-ascii?q?9a23=3Azz0coBDD7Nf517YJ6ITCUyQJP3N1i/DPJgcQr6Af?= =?us-ascii?q?oPdwSPT6psbcNUDSrc9gkEXOFd2Cra4c26yO6+jJYi8p2d65qncMcZhBBVcuqP?= =?us-ascii?q?49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6?= =?us-ascii?q?JvjvGo7Vks+7y/2+94fcbglUhzexe69+IAmrpgjNq8cahpdvJLwswRXTuHtIfO?= =?us-ascii?q?pWxWJsJV2Nmhv3+9m98p1+/SlOovwt78FPX7n0cKQ+VrxYES8pM3sp683xtBnM?= =?us-ascii?q?VhWA630BWWgLiBVIAgzF7BbnXpfttybxq+Rw1DWGMcDwULs5Qiqp4bt1RxD0iS?= =?us-ascii?q?cHLz85/3/Risxsl6JQvRatqwViz4LIfI2ZMfxzdb7fc9wHX2pMRsleVyJDD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EI2r?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DxAgAC0xtchzShVdFlDg8BAQUBBwUBg?= =?us-ascii?q?WWCKYFDJ4N9gR2CXpAZgg2JJohch1YNhGwCgmwaBwEENBIBAwEBAgEBAQEBEwE?= =?us-ascii?q?BAQgNCQgpIwyCNiQBgmIBAgMjHQEbHQEDAQsGAwILDSoCAiEBAREBBQEcBhODI?= =?us-ascii?q?oFpAQMVi3yQCDyLGYESBQEXgncFhDYKGScNXoE3AgYSjC2BVz+EI4JXhTKCVwK?= =?us-ascii?q?JJ4Y1f5AvMwcCgiUEjAqDMhiRXY9aiiQPIYE8gXdNI1AxgjuCGxqDU4oYXCEwA?= =?us-ascii?q?Y5mAQE?= X-IPAS-Result: =?us-ascii?q?A0DxAgAC0xtchzShVdFlDg8BAQUBBwUBgWWCKYFDJ4N9gR2?= =?us-ascii?q?CXpAZgg2JJohch1YNhGwCgmwaBwEENBIBAwEBAgEBAQEBEwEBAQgNCQgpIwyCN?= =?us-ascii?q?iQBgmIBAgMjHQEbHQEDAQsGAwILDSoCAiEBAREBBQEcBhODIoFpAQMVi3yQCDy?= =?us-ascii?q?LGYESBQEXgncFhDYKGScNXoE3AgYSjC2BVz+EI4JXhTKCVwKJJ4Y1f5AvMwcCg?= =?us-ascii?q?iUEjAqDMhiRXY9aiiQPIYE8gXdNI1AxgjuCGxqDU4oYXCEwAY5mAQE?= X-IronPort-AV: E=Sophos;i="5.56,378,1539640800"; d="scan'208,217";a="361297151" Received: from mail-yw1-f52.google.com ([209.85.161.52]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 20 Dec 2018 18:41:07 +0100 Received: by mail-yw1-f52.google.com with SMTP id i73so1011990ywg.3 for ; Thu, 20 Dec 2018 09:41:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fpxw+Kv/vaWu1CI8CCTgVF2jDozjiCuzIeamP9dDwCM=; b=fidrLINQOKZS5Yym482YtLsrLLLgIEHIm5p+++pDNvi2n+PHYEK+X3Qzk6IOseX1b3 jQs6l6JnhbKI8X7kSHQUMW5tOe97QuEY8f8w6rScEpVpdgLhuyyHRZpnAYVj/QZK0ylt 3+McCa1R1nA9Bk7kVdwlLxr9ioheXBaFEba2TfohGIPKyxuR9UgTmCYJMtn4PzLOhRXb XtujsLJdFjUwE938ACcBv5pjOk6HTUf9nvExyy2tS3uqf8yEF2nzl5nQqYqIdQz1nR2o UFE6NSrxuUAK9NjXmeDYRKWYTyLG/aWZZ47ruOwaEsbYpRyOGRI9HVSfarIkz5isZBjE GQkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fpxw+Kv/vaWu1CI8CCTgVF2jDozjiCuzIeamP9dDwCM=; b=ctKVJYoIL99xFZuEy8IKU4uknCC6c3M2BESAJfPqWNw/1nGdnCTE/eMWor4Qgl1dh/ zZfV/HiBDDEYdQJXlbaz/cxbcVtNLW5vU+fXjlz70usTK9TBx3RFQcE6yM9sUbJZLMud RIlYBopkyyvWr/PU95FsRjHt+E4PxpaUZcRAngZuWePd82ZQ+UAkLLxd2MUDknsnl85e 3yuNMQaooy7D06Mh/pcyHa5JQahRzzxPTfYUM8NDrsnGuj0i6i1hvZzNkBtfo8/uGHND tk4uedU9HZx3Cc1liPVBwjY36E8o7qN/zKLPYfHHSSA13E9WB2PySlshM3XT4cCt7BfZ 5KGw== X-Gm-Message-State: AA+aEWb7vStfcp/itZPzBdrBxQV4JF/Ma3Q7jTzmzSii3gAy7mQiUJxA kIrlWPKh3AfgIpu8Q5BxE9vfwIFh7y59vRn0z8ODlTWY X-Google-Smtp-Source: AFSGD/V+Jm3cOFxWU/dF7g0OGL8s5SqYAQ3oj/Yc36g926NW5qRoz6Q5LOS7Oq9ZP1qo54j0f5bhcMZgYVo0eJyX2N8= X-Received: by 2002:a81:e50d:: with SMTP id s13mr27283220ywl.405.1545327666466; Thu, 20 Dec 2018 09:41:06 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Lindsay Errington Date: Thu, 20 Dec 2018 09:40:56 -0800 Message-ID: To: Stephen Dolan Cc: Ocaml Mailing List Content-Type: multipart/alternative; boundary="0000000000009f13bb057d77a241" Subject: Re: [Caml-list] Possible ephemeron bug? Reply-To: Lindsay Errington X-Loop: caml-list@inria.fr X-Sequence: 17256 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --0000000000009f13bb057d77a241 Content-Type: text/plain; charset="UTF-8" Great answer! Thanks to you both. I have a followup ephemeron question which I'll post with a different subject. On Thu, Dec 20, 2018 at 1:46 AM Stephen Dolan wrote: > On Thu, 20 Dec 2018 at 00:30, Lindsay Errington < > lindsay.errington@gmail.com> wrote: > >> If however, I use the standalone bytecode compiler or the native compiler >> (4.07.1), then the entries are not nullified. Is this a bug or is there >> another way to persuade the garbage collector to clobber the entries? >> > > Thanks for the detailed example! > > The issue is with the test code at the end: > > let (root,map) = > let map = [] in > let (k0,map) = intern 0 (str 1) map in > let (k1,map) = intern 1 (Link k0) map in > let (k2,map) = intern 2 (Link k1) map in > (k2,map);; > > Fmt.printf "root=%a, map=@[%a@]@." pp_key root pp_map map;; > > let map = upd root (str 2) map;; > > Fmt.printf "root=%a map1=@[%a@]@." pp_key root pp_map map;; > > Both the bytecode and native code compilers take any value bound to a > global to be reachable forever, even if that global is later shadowed by > another global of the same name. The ephemerons don't get cleared, because > the original map is still alive. > > You can change the code to avoid putting the original map in a global > constant: > > let (root, map) = > let map = [] in > let (k0,map) = intern 0 (str 1) map in > let (k1,map) = intern 1 (Link k0) map in > let (k2,map) = intern 2 (Link k1) map in > Fmt.printf "root=%a, map=@[%a@]@." pp_key k2 pp_map map; > let map = upd k2 (str 2) map in > (k2, map);; > > Fmt.printf "root=%a map1=@[%a@]@." pp_key root pp_map map;; > > With this version, the original map becomes unreachable, so the GC can > clear the ephemerons. > > Stephen > -- Caml-list mailing list. Subscription management and archives: https://sympa.inria.fr/sympa/arc/caml-list https://inbox.ocaml.org/caml-list Forum: https://discuss.ocaml.org/ Bug reports: http://caml.inria.fr/bin/caml-bugs --0000000000009f13bb057d77a241 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Great answer! Thanks to you both.

I hav= e a followup ephemeron question which I'll post with a different subjec= t.

On Thu, Dec 2= 0, 2018 at 1:46 AM Stephen Dolan <stephen.dolan@cl.cam.ac.uk> wrote:
On Thu, 20 Dec 2018 at 00:30, Lindsay Errington <lindsay.errington@gmail.= com> wrote:
If however, I use the standal= one bytecode compiler or the native compiler (4.07.1), then the entries are= not nullified. Is this a bug or is there another way to persuade the garba= ge collector to clobber the entries?

Thanks for the detailed example!

The issue is with the test code at the end:

<= /div>
<= div dir=3D"ltr">
=C2=A0 =C2=A0 let (roo= t,map) =3D
=C2=A0 =C2=A0 =C2=A0 let map =3D [] in
=C2= =A0 =C2=A0 =C2=A0 let (k0,map) =3D intern 0 (str 1) map in
=C2=A0= =C2=A0 =C2=A0 let (k1,map) =3D intern 1 (Link k0) map in
=C2=A0 = =C2=A0 =C2=A0 let (k2,map) =3D intern 2 (Link k1) map in
=C2=A0 = =C2=A0 =C2=A0 (k2,map);;
=C2=A0 =C2=A0=C2=A0
=C2=A0 =C2=A0 Fmt.printf "root=3D%a, map= =3D@[<v>%a@]@." pp_key root pp_map map;;
=
=C2=A0 =C2=A0=C2=A0
=C2=A0 =C2=A0 let = map =3D upd root (str 2) map;;
=C2=A0 =C2=A0=C2=A0
=C2=A0 =C2=A0 Fmt.printf "root=3D%a = map1=3D@[<v>%a@]@." pp_key root pp_map map;;
Both the bytecode and native code compilers take any value boun= d to a global to be reachable forever, even if that global is later shadowe= d by another global of the same name. The ephemerons don't get cleared,= because the original map is still alive.

You can = change the code to avoid putting the original map in a global constant:

=C2=A0 =C2=A0 let (root, map) =3D
=C2=A0 =C2=A0 =C2=A0 let map =3D [] in
=C2=A0 =C2=A0 =C2=A0 let (k0,map) =3D intern 0 (str 1) map in
=
=C2=A0 =C2=A0 =C2=A0 let (k1,map) =3D intern 1 (Link k0) map in
<= div>=C2=A0 =C2=A0 =C2=A0 let (k2,map) =3D intern 2 (Link k1) map in
=C2=A0 =C2=A0 =C2=A0 Fmt.printf &q= uot;root=3D%a, map=3D@[<v>%a@]@." pp_key k2 pp_map map;
=C2=A0 =C2=A0 =C2=A0 let map =3D upd k2 (str 2) map in
=C2=A0 = =C2=A0 =C2=A0 (k2, map);;
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0
=
=C2=A0 =C2=A0 Fmt.printf "root=3D%a map1=3D@[<v>%a@]@."= ; pp_key root pp_map map;;

With this version= , the original map becomes unreachable, so the GC can clear the ephemerons.=

Stephen
--0000000000009f13bb057d77a241--