[gambit-list] Table resizing bug?

Marc Feeley feeley at iro.umontreal.ca
Tue Feb 13 13:54:17 EST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On 31-Jan-07, at 4:33 AM, TJ wrote:

> Running the following code in gambit's repl causes its memory usage to
> shoot up and end up making the whole pc unresponsive.
>
> (define t (make-table min-load: 0.75 max-load: 0.95))
> (table-set! t 0 0)
> (table-set! t 1 1)
> (table-set! t 2 2)
> (table-set! t 3 3)
> (table-set! t 4 4)

Fixed.  This was an off-by-one error in the computation of the new  
table size (the code was truncating a float instead of computing the  
ceiling).  Because of this the new table was the same size, so when  
the elements were transferred to the new table it caused a new  
attempt to resize the table, and so on forever.

You can correct the problem by replacing the head of procedure ##gc- 
hash-table-resize! in lib/_system.scm by:

(define-prim (##gc-hash-table-resize! gcht loads)
   (let* ((count
           (macro-gc-hash-table-count gcht))
          (n
           (##fixnum.+ 1
                       (##flonum.->fixnum
                        (##flonum./ (##flonum.<-fixnum count)
                                    (##f64vector-ref loads 1))))))


Marc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFF0gla//V9Zc2T/v4RAgigAJ9oXpOWsmYXcPUnX7vSD+vc16ZViQCfUjYF
4pmZH+eZXpKsyqvdM2p+EDY=
=n/K6
-----END PGP SIGNATURE-----



More information about the Gambit-list mailing list