GNU bug report logs - #9900
Using a guardian on a value in a weak hash

Previous Next

Package: guile;

Reported by: Ian Price <ianprice90 <at> googlemail.com>

Date: Fri, 28 Oct 2011 20:47:02 UTC

Severity: normal

Done: Andy Wingo <wingo <at> pobox.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Ian Price <ianprice90 <at> googlemail.com>
Subject: bug#9900: closed (Re: bug#9900: Using a guardian on a value in a
 weak hash)
Date: Wed, 09 Nov 2011 22:48:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#9900: Using a guardian on a value in a weak hash

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 9900 <at> debbugs.gnu.org.

-- 
9900: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9900
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Andy Wingo <wingo <at> pobox.com>
To: Ian Price <ianprice90 <at> googlemail.com>
Cc: 9900-done <at> debbugs.gnu.org
Subject: Re: bug#9900: Using a guardian on a value in a weak hash
Date: Wed, 09 Nov 2011 23:47:04 +0100
I believe I have fixed this bug in stable-2.0.  Thanks for the report!

Andy
-- 
http://wingolog.org/

[Message part 3 (message/rfc822, inline)]
From: Ian Price <ianprice90 <at> googlemail.com>
To: bug-guile <at> gnu.org
Subject: Using a guardian on a value in a weak hash
Date: Fri, 28 Oct 2011 21:42:45 +0100
Hi guilers,

If I 'guard' a value, and store it in a weak-key hashtable, then it
doesn't appear in the guardian even after it is removed from the
weak-hash by a garbage collection. Note, this only happens in a
_script_, and will work fine in a REPL (you should only need two GCs,
one for the weak hash, and one for the now free value).
e.g.


(define guardian (make-guardian))
(define finalizer-table (make-weak-key-hash-table))

(let ((f (lambda () (display "test\n"))))
  (guardian f)
  (hashq-set! finalizer-table (cons #f #f) f)
  #f)

(write finalizer-table)
(newline)

(gc)(gc)(gc)(gc)(gc)(gc)(gc)(gc)(gc)(gc)(gc)(gc)

(write finalizer-table)
(newline)

(write (guardian))
(newline)


will produce the output


[ian <at> Kagami guile]$ guile -s /tmp/gcbug.scm 
#<weak−key−hash−table 1/31>
#<weak−key−hash−table 0/31>
#f
[ian <at> Kagami guile]$ 

-- 
Ian Price

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"




This bug report was last modified 13 years and 156 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.