GNU bug report logs - #25743
rehash-size ignored

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> IRO.UMontreal.CA>

Date: Wed, 15 Feb 2017 19:20:02 UTC

Severity: normal

Found in version 26.0.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 25743 <at> debbugs.gnu.org
Subject: bug#25743: rehash-size ignored
Date: Fri, 26 Jul 2019 15:55:07 +0200
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:

> Looking accidentally at maybe_resize_hash_table, I noticed that we don't
> obey resize_hash, although we do all the work needed for that.
> Worse, we make dangerous assumptions about the behavior of
> larger_vector:
>
> maybe_resize_hash_table takes `old_size' from `ASIZE (h->next)' and then
> uses rehash_size to compute the desired new_size.  The problem comes
> here:
>
>       set_hash_key_and_value (h, larger_vector (h->key_and_value,
> 						2 * (new_size - old_size), -1));
>       set_hash_next (h, larger_vector (h->next, new_size - old_size, -1));
>
> This says, that h->next and h->key_and_value are replaced by new vectors
> that are larger than the previous one so that they are large enough to
> accomodate new_size.

I did not follow the recent thread about hash table resizing closely,
but I do seem to remember somebody saying that they'd fixed something in
the hash resizing code, and the commits in fns.c seem to back that up:

commit 49e80e765b693736a8bb97ae5bfa341d25bf4f02
Author: Paul Eggert <eggert <at> cs.ucla.edu>
Date:   Sat Jul 20 23:21:14 2019 -0700

    Tweak recent hash-table fix
    
    * src/fns.c (maybe_resize_hash_table): Completely initialize the
    new ‘next’ vector before allocating more vectors, as this
    preserves locality a bit better and it’s safer not to leave an
    uninitialized Lisp object around.  Use next_size instead of
    new_size to compute new index size.

So is the issue discussed in this bug report fixed now?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 5 years and 300 days ago.

Previous Next


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