Subject: Re: bug#36447: 27.0.50; New "Unknown keyword" errors

From: Pip Cet <[email-masked]>
Date: Tue, 2 Jul 2019 22:50:54 +0000

On Tue, Jul 2, 2019 at 4:20 PM Noam Postavsky <[email-masked]> wrote:
> Michael Heerdegen <[email-masked]> writes:
> > Pip Cet <[email-masked]> writes:
> >> > Hmm - seems so, yes.  I just made bootstrap with the commit
> >> > included, and the problem is still gone.  Strange thing, but seems
> >> > there is nothing to fix.
> >>
> >> I'm not sure I agree. Something went wrong somewhere, or we wouldn't
> >> have called byte code with what looks like an invalid hash table.
> >
> > Did you reply to the wrong thread - or - where is a connection to hash
> > tables?
>
> The compiler translates repeated `eq' in a cond like that into a hash
> and jump.  See byte-compile-cond-use-jump-table.

I think I found the problem. It's a bit tricky.

When we purecopy the hash tables emitted by the byte code compiler,
Vpurify_flag is a hash table with predicate 'equal. That means the
->next vectors for different hash tables now might refer to the same
pure vector.

Rehashing such a hash table thus destroys another hash table's ->next
vector, so it shouldn't happen.

pdumper.c forces rehashing of many hash tables, including pure ones.

The attached patch "fixes" things, at a high price. I'll try coming up
with a proper fix soon if no one beats me to it.

(To reproduce the problem, I added these lines to fn.c:

   DEFSYM (QCrehash_size, ":rehash-size");
   DEFSYM (QCrehash_threshold, ":rehash-threshold");
   DEFSYM (QCweakness, ":weakness");
+  DEFSYM (QCgroup, ":group");
+  DEFSYM (QCversion, ":version");
+  DEFSYM (QCpackage_version, ":package-version");
+  DEFSYM (QClink, ":link");
+  DEFSYM (QCload, ":load");
+  DEFSYM (QCtag, ":tag");
+  DEFSYM (QCset_after, ":set-after");
   DEFSYM (Qkey, "key");
   DEFSYM (Qvalue, "value"); )
From 20b63dce1695cfc2dfa94961d03da88a4cceaffb Mon Sep 17 00:00:00 2001
From: Pip Cet <[email-masked]>
Date: Tue, 2 Jul 2019 22:48:23 +0000
Subject: [PATCH] Fix bug#36477

---
 src/fns.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/fns.c b/src/fns.c
index 2fc000a7f4..375b7d2841 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4223,6 +4223,11 @@ hash_table_rehash (struct Lisp_Hash_Table *h)
 {
   ptrdiff_t size = HASH_TABLE_SIZE (h);
 
+  h->next = Fcopy_sequence (h->next);
+  h->index = Fcopy_sequence (h->index);
+  h->hash = Fcopy_sequence (h->hash);
+  h->key_and_value = Fcopy_sequence (h->key_and_value);
+
   /* Recompute the actual hash codes for each entry in the table.
      Order is still invalid.  */
   for (ptrdiff_t i = 0; i < size; ++i)
-- 
2.20.1