From unknown Thu Jun 19 13:59:41 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#25743 <25743@debbugs.gnu.org> To: bug#25743 <25743@debbugs.gnu.org> Subject: Status: rehash-size ignored Reply-To: bug#25743 <25743@debbugs.gnu.org> Date: Thu, 19 Jun 2025 20:59:41 +0000 retitle 25743 rehash-size ignored reassign 25743 emacs submitter 25743 Stefan Monnier severity 25743 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 15 14:19:13 2017 Received: (at submit) by debbugs.gnu.org; 15 Feb 2017 19:19:13 +0000 Received: from localhost ([127.0.0.1]:41346 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ce56e-00067L-TP for submit@debbugs.gnu.org; Wed, 15 Feb 2017 14:19:13 -0500 Received: from eggs.gnu.org ([208.118.235.92]:40756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ce56c-000679-TA for submit@debbugs.gnu.org; Wed, 15 Feb 2017 14:19:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ce56V-0002js-VS for submit@debbugs.gnu.org; Wed, 15 Feb 2017 14:19:05 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:41073) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ce56V-0002jo-SZ for submit@debbugs.gnu.org; Wed, 15 Feb 2017 14:19:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ce56T-0006yf-UR for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2017 14:19:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ce56Q-0002j2-Oi for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2017 14:19:01 -0500 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:36980) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ce56Q-0002ik-I5 for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2017 14:18:58 -0500 Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id v1FJIs6H005192 for ; Wed, 15 Feb 2017 14:18:54 -0500 Received: by pastel.home (Postfix, from userid 20848) id 475F660594; Wed, 15 Feb 2017 14:18:54 -0500 (EST) From: Stefan Monnier To: bug-gnu-emacs@gnu.org Subject: rehash-size ignored Date: Wed, 15 Feb 2017 14:18:54 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Level: X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0.3 X-NAI-Spam-Rules: 5 Rules triggered BEC_TRC1=0.1, BEC_TRC1_W_GEN_SPAM_FEATRE=0.1, GEN_SPAM_FEATRE=0.1, EDT_SA_DN_PASS=0, RV5949=0 X-NAI-Spam-Version: 2.3.0.9418 : core <5949> : inlines <5699> : streams <1733073> : uri <2377740> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Package: Emacs Version: 26.0.50 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. The problem is that larger_vector's promise is to return a vector at least as large as requested, but sometimes larger. In practice the new vector is twice the size of the old vector. This means that rehash_size is ignored when it means to something smaller than twice the size. It *also* means that h->next may end up larger than planned. But `ASIZE (h->next)' is the definition of the hash-table's size, so if it's larger than planned, then it's indispensible to make sure that all other related tables are equally larger: h->key_and_value must always be at least twice the size of h->next. But the call above only makes sure the new h->key_and_value is at least twice the desired new_size but not twice the size of the new h->next. I think the right fix is to change the calls to larger_vector so that instead of requesting vectors "at least as large as new_size", we should request vectors "of size exactly new_size". That will fix both problems at the same time. The patch below implements it. Any objection? Stefan diff --git a/src/fns.c b/src/fns.c index 760a017dedf..62c834fac60 100644 --- a/src/fns.c +++ b/src/fns.c @@ -3536,19 +3535,19 @@ get_key_arg (Lisp_Object key, ptrdiff_t nargs, Lisp_Object *args, char *used) Lisp_Object larger_vector (Lisp_Object vec, ptrdiff_t incr_min, ptrdiff_t nitems_max) { + eassert (VECTORP (vec)); struct Lisp_Vector *v; - ptrdiff_t incr, incr_max, old_size, new_size; + ptrdiff_t old_size = ASIZE (vec); ptrdiff_t C_language_max = min (PTRDIFF_MAX, SIZE_MAX) / sizeof *v->contents; - ptrdiff_t n_max = (0 <= nitems_max && nitems_max < C_language_max + ptrdiff_t n_max = (nitems_max == 0 ? old_size + incr_min + : 0 < nitems_max && nitems_max < C_language_max ? nitems_max : C_language_max); - eassert (VECTORP (vec)); eassert (0 < incr_min && -1 <= nitems_max); - old_size = ASIZE (vec); - incr_max = n_max - old_size; - incr = max (incr_min, min (old_size >> 1, incr_max)); + ptrdiff_t incr_max = n_max - old_size; + ptrdiff_t incr = max (incr_min, min (old_size >> 1, incr_max)); if (incr_max < incr) memory_full (SIZE_MAX); - new_size = old_size + incr; + ptrdiff_t new_size = old_size + incr; v = allocate_vector (new_size); memcpy (v->contents, XVECTOR (vec)->contents, old_size * sizeof *v->contents); memclear (v->contents + old_size, incr * word_size); @@ -3828,10 +3827,10 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h) message ("Growing hash table to: %"pI"d", new_size); #endif - 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)); - set_hash_hash (h, larger_vector (h->hash, new_size - old_size, -1)); + set_hash_key_and_value (h, larger_vector (h->key_and_value, + 2 * (new_size - old_size), 0)); + set_hash_next (h, larger_vector (h->next, new_size - old_size, 0)); + set_hash_hash (h, larger_vector (h->hash, new_size - old_size, 0)); set_hash_index (h, Fmake_vector (make_number (index_size), Qnil)); /* Update the free list. Do it so that new entries are added at In GNU Emacs 26.0.50.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars) of 2017-01-30 built on lechazo Repository revision: 5ddca31bf707686aafaf891c216702b64657c516 Windowing system distributor 'The X.Org Foundation', version 11.0.11900000 System Description: Debian GNU/Linux 9.0 (stretch) Recent messages: Wrote /home/monnier/src/emacs/work/src/fns.c Saving file /home/monnier/src/emacs/work/src/fns.c... Wrote /home/monnier/src/emacs/work/src/fns.c previous-line: Beginning of buffer [2 times] Hunk already applied Mark set Saving file /home/monnier/src/emacs/work/src/fns.c... Wrote /home/monnier/src/emacs/work/src/fns.c Saving file /home/monnier/src/emacs/work/src/fns.c... Wrote /home/monnier/src/emacs/work/src/fns.c Configured using: 'configure -C --enable-checking --enable-check-lisp-object-type 'CFLAGS=-Wall -g3 -Og -Wno-pointer-sign' PKG_CONFIG_PATH=/home/monnier/lib/pkgconfig' Configured features: XAW3D XPM JPEG TIFF GIF PNG SOUND GPM DBUS GSETTINGS NOTIFY GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11 Important settings: value of $LANG: fr_CH.UTF-8 locale-coding-system: utf-8-unix Major mode: InactiveMinibuffer Minor modes in effect: csv-field-index-mode: t diff-auto-refine-mode: t shell-dirtrack-mode: t electric-pair-mode: t global-reveal-mode: t reveal-mode: t auto-insert-mode: t savehist-mode: t minibuffer-electric-default-mode: t global-compact-docstrings-mode: t url-handler-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t global-prettify-symbols-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: /home/monnier/src/emacs/elpa/packages/svg/svg hides /home/monnier/src/emacs/work/lisp/svg /home/monnier/src/emacs/elpa/packages/ada-mode/ada-xref hides /home/monnier/src/emacs/work/lisp/progmodes/ada-xref /home/monnier/src/emacs/elpa/packages/ada-mode/ada-stmt hides /home/monnier/src/emacs/work/lisp/progmodes/ada-stmt /home/monnier/src/emacs/elpa/packages/ada-mode/ada-prj hides /home/monnier/src/emacs/work/lisp/progmodes/ada-prj /home/monnier/src/emacs/elpa/packages/ada-mode/ada-mode hides /home/monnier/src/emacs/work/lisp/progmodes/ada-mode /home/monnier/src/emacs/elpa/packages/landmark/landmark hides /home/monnier/src/emacs/work/lisp/obsolete/landmark /home/monnier/src/emacs/elpa/packages/crisp/crisp hides /home/monnier/src/emacs/work/lisp/obsolete/crisp Features: (shadow mail-extr emacsbug message puny rfc822 mml mml-sec epa derived epg mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail grep csv-mode smerge-mode whitespace gud debug completion tar-mode dabbrev vc vc-dispatcher caml tuareg_indent tuareg caml-help caml-types caml-emacs map sm-c-mode smie ox-latex ox-icalendar ox-html ox-ascii ox-publish ox org-protocol org-mouse org-mobile org-agenda org-indent org-feed org-crypt org-capture org-attach org-id org-element org-rmail org-mhe org-irc org-info org-gnus gnus-util rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils org-docview org-bibtex org-bbdb org-w3m org org-macro org-footnote org-pcomplete org-list org-faces org-entities org-version ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table ob-exp org-src ob-keys ob-comint ob-core ob-eval org-compat org-macs org-loaddefs bibtex-style bibtex rect skeleton eieio-opt speedbar sb-image ezimage dframe find-func help-fns radix-tree html5-schema rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap sgml-mode dom nxml-util nxml-enc xmltok sort mpc view cal-china lunar solar cal-dst cal-bahai cal-islam cal-hebrew holidays hol-loaddefs warnings cal-french diary-lib diary-loaddefs cal-move cal-menu calendar cal-loaddefs misearch multi-isearch cus-edit cus-start cus-load wid-edit autorevert filenotify doc-view subr-x jka-compr image-mode dired dired-loaddefs format-spec executable copyright vc-git diff-mode filecache reftex-dcr reftex reftex-loaddefs reftex-vars tex-mode compile shell pcomplete comint ansi-color ring latexenc server time-date noutline outline easy-mmode flyspell ispell checkdoc thingatpt load-dir elec-pair reveal autoinsert proof-site proof-autoloads cl pg-vars savehist minibuf-eldef disp-table compact-docstrings kotl-loaddefs advice info realgud-recursive-autoloads finder-inf url-auth package epg-config url-handlers url-parse auth-source eieio eieio-core cl-macs eieio-loaddefs password-cache url-vars seq byte-opt gv bytecomp byte-compile cl-extra help-mode easymenu cconv cl-loaddefs pcase cl-lib bbdb-loaddefs mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify dynamic-setting system-font-setting font-render-setting x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 8 523925 99482) (symbols 24 37808 0) (miscs 20 5334 863) (strings 16 112634 17461) (string-bytes 1 4377921) (vectors 8 68327) (vector-slots 4 2220644 87010) (floats 8 1387 1336) (intervals 28 30482 0) (buffers 520 88)) From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 26 09:55:17 2019 Received: (at 25743) by debbugs.gnu.org; 26 Jul 2019 13:55:17 +0000 Received: from localhost ([127.0.0.1]:41581 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hr0gn-0001Dr-3Z for submit@debbugs.gnu.org; Fri, 26 Jul 2019 09:55:17 -0400 Received: from quimby.gnus.org ([80.91.231.51]:34198) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hr0gj-0001Ag-Dy for 25743@debbugs.gnu.org; Fri, 26 Jul 2019 09:55:14 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hr0ge-0006wD-AR; Fri, 26 Jul 2019 15:55:10 +0200 From: Lars Ingebrigtsen To: Stefan Monnier Subject: Re: bug#25743: rehash-size ignored References: Date: Fri, 26 Jul 2019 15:55:07 +0200 In-Reply-To: (Stefan Monnier's message of "Wed, 15 Feb 2017 14:18:54 -0500") Message-ID: <87tvb8lx38.fsf@mouse.gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Stefan Monnier 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 [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 25743 Cc: 25743@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier 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 Date: Sat Jul 20 23:21:14 2019 -0700 Tweak recent hash-table fix =20=20=20=20 * src/fns.c (maybe_resize_hash_table): Completely initialize the new =E2=80=98next=E2=80=99 vector before allocating more vectors, as th= is preserves locality a bit better and it=E2=80=99s 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? --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 26 13:16:22 2019 Received: (at 25743-done) by debbugs.gnu.org; 26 Jul 2019 17:16:22 +0000 Received: from localhost ([127.0.0.1]:43310 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hr3pO-0000Lt-FN for submit@debbugs.gnu.org; Fri, 26 Jul 2019 13:16:22 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:57837) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hr3pM-0000Lf-0b for 25743-done@debbugs.gnu.org; Fri, 26 Jul 2019 13:16:20 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 6C656102D83; Fri, 26 Jul 2019 13:16:14 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id CD94E1013C1; Fri, 26 Jul 2019 13:16:12 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1564161372; bh=aKIRg8ltqDPjjoZsmQ/XOJqHopXfnQ2ftlNfIV7oI7E=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=aURjxS/zbMu/0hyqsn85PSTb+9KnBCFLA9QVhcDwP1g0cGDfkev5khlUh8xsMQ0rb HgvrdV0MVTc4s/NLf0oSQFnILkLhA72tWcBCGRmmlVZsJTcjioGyQDUKkjzgzWKu/F Dkgo81BpEG1R0ArPQPAOzSnGgKtP95s+zLo+9ZIiILZ3CwWMvBr2EM7DF426XRLFxv fMf4HrZMl5ubpioltbypzXhPzF1fvtyG05e4HMVL1eB6vFfXQxgc4QIUYuR4fVeDri HYX5YocF5boCRFh2DimvLjEiS0O7qOGwNo19HvBnUbXb8IL4Mdztt0ZgT47cZU5Nqc XCO2QVn6+rrMw== Received: from alfajor (modemcable157.163-203-24.mc.videotron.ca [24.203.163.157]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9A8AD120C2D; Fri, 26 Jul 2019 13:16:12 -0400 (EDT) From: Stefan Monnier To: Lars Ingebrigtsen Subject: Re: bug#25743: rehash-size ignored Message-ID: References: <87tvb8lx38.fsf@mouse.gnus.org> Date: Fri, 26 Jul 2019 13:16:10 -0400 In-Reply-To: <87tvb8lx38.fsf@mouse.gnus.org> (Lars Ingebrigtsen's message of "Fri, 26 Jul 2019 15:55:07 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.135 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 25743-done Cc: 25743-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > * src/fns.c (maybe_resize_hash_table): Completely initialize the > new =E2=80=98next=E2=80=99 vector before allocating more vectors, as = this > preserves locality a bit better and it=E2=80=99s 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? This patch fixes the most severe problem (which was that the table was larger than requested and we didn't take it into account in the rest of the code). But it doesn't fix the problem in the title: by default rehash-size is 1.5 yet in practice the code just doubles the size (because larger_vecalloc only allocates something smaller than twice the original size when we're reaching the maximum possible size). So I installed the patch below to finish it. Thanks, Stefan diff --git a/src/fns.c b/src/fns.c index f4f3b95ac6..c45f455646 100644 --- a/src/fns.c +++ b/src/fns.c @@ -4190,7 +4190,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h) avoid problems if memory is exhausted. larger_vecalloc finishes computing the size of the replacement vectors. */ Lisp_Object next =3D larger_vecalloc (h->next, new_size - old_size, - PTRDIFF_MAX / 2); + new_size); ptrdiff_t next_size =3D ASIZE (next); for (ptrdiff_t i =3D old_size; i < next_size - 1; i++) gc_aset (next, i, make_fixnum (i + 1)); From unknown Thu Jun 19 13:59:41 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 24 Aug 2019 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator