[Openmcl-devel] strange(?) hash-table-count on weak hash table
gb at clozure.com
Wed Jun 18 23:13:40 PDT 2014
It's a bug; it should be fixed in the trunk in r16119.
On Wed, 18 Jun 2014, Jared C. Davis wrote:
> I was experimenting with weak hash tables and have run into something I don't
> understand. Here's a small example, taken on 1.10-dev-r16074M-trunk
> (defparameter *ht* (make-hash-table :weak :key :test 'eq))
> (defparameter *key* (cons 1 2))
> (setf (gethash *key* *ht*) 17)
> (hash-table-count *ht*) ;; 1, as I expected
> (hash-table-count *ht*) ;; 1, as I expected since *key* is obviously reachable
> nil ;; try to clear out *, **, ***
> (hash-table-count *ht*) ;; 1, as I expected since *key* is still reachable
> (setf *key* nil) ;; The (cons 1 2) should now be unreachable, right?
> (gc) ;; So this should free the hash table entry
> (hash-table-count *ht*) ;; 2 --- er, what the heck?!?
> I had expected the final line above to report 0 instead of 2. I wouldn't have
> been entirely surprised by a count of 1, but how in the world did the count
> increase? Is this expected?
> Jared C. Davis <jared at cs.utexas.edu>
> 11410 Windermere Meadows
> Austin, TX 78759
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
More information about the Openmcl-devel