Opened 8 years ago

Last modified 6 years ago

#1293 new defect

Locatives get moved around causing hash tables to lose them — at Initial Version

Reported by: sjamaan Owned by:
Priority: critical Milestone: someday
Component: core libraries Version: 4.10.x
Keywords: srfi-69, hash tables, locatives Cc:
Estimated difficulty: hard

Description

As pointed out by John Croisant:

;; Even though the filler slots are not used, if you remove any of
;; them, the hash of the instance will change after GC, causing the
;; hash table lookup to fail.

(use srfi-69 lolevel)

(define table (make-hash-table test: eq? hash: eq?-hash))

(define-record-type box
  (make-box contents)
  box?
  ;; Remove or comment out any of the next three lines:
  (filler1  box-filler1)
  (filler2  box-filler2)
  (filler3  box-filler3)
  (contents box-contents))

(define my-box (make-box (make-locative "foo")))

(hash-table-set! table my-box #t)

(printf "before gc, hash table contains ~S? ~S~N"
        my-box
        (hash-table-exists? table my-box))

(gc)

(printf "after gc,  hash table contains ~S? ~S~N"
        my-box
        (hash-table-exists? table my-box))

(printf "hash table as alist: ~S~N"
        (hash-table->alist table))

Change History (0)

Note: See TracTickets for help on using tickets.