From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Price Newsgroups: gmane.lisp.guile.bugs Subject: bug#9900: Using a guardian on a value in a weak hash Date: Sat, 29 Oct 2011 19:51:11 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1319914450 16049 80.91.229.12 (29 Oct 2011 18:54:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 29 Oct 2011 18:54:10 +0000 (UTC) Cc: 9900@debbugs.gnu.org To: Stefan Israelsson Tampe Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sat Oct 29 20:54:06 2011 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RKE2g-0004Js-2N for guile-bugs@m.gmane.org; Sat, 29 Oct 2011 20:54:06 +0200 Original-Received: from localhost ([::1]:54986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKE2f-0003M5-2Q for guile-bugs@m.gmane.org; Sat, 29 Oct 2011 14:54:05 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:34928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKE2c-0003Lv-Pr for bug-guile@gnu.org; Sat, 29 Oct 2011 14:54:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RKE2b-0004ni-Bo for bug-guile@gnu.org; Sat, 29 Oct 2011 14:54:02 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKE2b-0004ne-9k for bug-guile@gnu.org; Sat, 29 Oct 2011 14:54:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RKE4Y-0007Zu-8j for bug-guile@gnu.org; Sat, 29 Oct 2011 14:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ian Price Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 29 Oct 2011 18:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9900 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 9900-submit@debbugs.gnu.org id=B9900.131991450429038 (code B ref 9900); Sat, 29 Oct 2011 18:56:02 +0000 Original-Received: (at 9900) by debbugs.gnu.org; 29 Oct 2011 18:55:04 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RKE3c-0007YJ-6P for submit@debbugs.gnu.org; Sat, 29 Oct 2011 14:55:04 -0400 Original-Received: from mail-wy0-f172.google.com ([74.125.82.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RKE3Y-0007Xt-RP for 9900@debbugs.gnu.org; Sat, 29 Oct 2011 14:55:02 -0400 Original-Received: by wyh22 with SMTP id 22so4666412wyh.3 for <9900@debbugs.gnu.org>; Sat, 29 Oct 2011 11:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=0AfedF4tX422HOlj2/Hz270Vyd0EzJiDnioskLkcUCo=; b=fO9cHZhu0A/G5sqyMm1BKmUINd+0gwM7lrcqHEFGEfOsckM6FuaSjkRgZ7gRyiayBc 3SIvYJzEdUK/5Lplz8Sm/RitL4mW9ls1OOc5n83ig5QuX5yM81PIwuAXmmTI29CsNmrC PYUcl9xuBuEA4JttIrYQSiikhYQnhLoyyL6YE= Original-Received: by 10.227.204.135 with SMTP id fm7mr10188523wbb.2.1319914378353; Sat, 29 Oct 2011 11:52:58 -0700 (PDT) Original-Received: from Kagami (host86-169-103-210.range86-169.btcentralplus.com. [86.169.103.210]) by mx.google.com with ESMTPS id et20sm215952wbb.15.2011.10.29.11.52.57 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 29 Oct 2011 11:52:57 -0700 (PDT) In-Reply-To: (Stefan Israelsson Tampe's message of "Sat, 29 Oct 2011 19:42:13 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 29 Oct 2011 14:56:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:5896 Archived-At: Stefan Israelsson Tampe writes: > f below in the code is referencing a direct function and not a closure th= at is not gc:able it seams > although there is no references to it. It looks like the loaded file refe= rences that code and it will not be > gc:ed until the same file is loaded again (make sure to save the old guar= dian so that one can inspect) This does seem to be the case scheme@(guile=E2=88=92user)> (load "gcbug.scm") ;;; note: source file /tmp/gcbug.scm ;;; newer than compiled /home/ian/.cache/guile/ccache/2.0=E2=88=92LE= =E2=88=924=E2=88=922.0/tmp/gcbug.scm.go ;;; note: auto=E2=88=92compilation is enabled, set GUILE_AUTO_COMPILE=3D0 ;;; or pass the =E2=88=92=E2=88=92no=E2=88=92auto=E2=88=92compile arg= ument to disable. ;;; compiling /tmp/gcbug.scm ;;; compiled /home/ian/.cache/guile/ccache/2.0=E2=88=92LE=E2=88=924=E2=88= =922.0/tmp/gcbug.scm.go # # #f scheme@(guile=E2=88=92user)> guardian $1 =3D # scheme@(guile=E2=88=92user)> (guardian) $2 =3D #f scheme@(guile=E2=88=92user)> (guardian) $3 =3D #f scheme@(guile=E2=88=92user)> (define k guardian) scheme@(guile=E2=88=92user)> (load "gcbug.scm") # # #f scheme@(guile=E2=88=92user)> (guardian) $4 =3D #f scheme@(guile=E2=88=92user)> (guardian) $5 =3D #f scheme@(guile=E2=88=92user)> (k) $6 =3D (foo . foo) scheme@(guile=E2=88=92user)> (k) $7 =3D #f scheme@(guile=E2=88=92user)>=20 here, f is the pair (foo . foo). > The weak key hastable is wrongly used and swaping key and value gives > correct behavior I disagree. While I would certainly expect it to work if I made the reference to f weak, it would miss the point of my code entirely. Namely to make sure that f isn't gc'd until after some other value is (hence the weak reference to a cons, and my comment about expecting to need 2 gcs). FWIW, I swapped it and ran again [ian@Kagami tmp]$ guile -s gcbug.scm=20 ;;; note: source file /tmp/gcbug.scm ;;; newer than compiled /home/ian/.cache/guile/ccache/2.0=E2=88=92LE= =E2=88=924=E2=88=922.0/tmp/gcbug.scm.go ;;; note: auto=E2=88=92compilation is enabled, set GUILE_AUTO_COMPILE=3D0 ;;; or pass the =E2=88=92=E2=88=92no=E2=88=92auto=E2=88=92compile arg= ument to disable. ;;; compiling /tmp/gcbug.scm ;;; compiled /home/ian/.cache/guile/ccache/2.0=E2=88=92LE=E2=88=924=E2=88= =922.0/tmp/gcbug.scm.go # # #f which isn't correct either, but not surprising if something else is holding onto f. --=20 Ian Price "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled"