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

From: Pip Cet <[email-masked]>
Date: Mon, 8 Jul 2019 17:58:42 +0000

On Mon, Jul 8, 2019 at 5:30 PM Lars Ingebrigtsen <[email-masked]> wrote:
> I'm still seeing this...  but not after every recompilation.  If I say
> "make bootstrap", then Emacs usually works.  If I then recompile parts,
> I sometimes get a non-working Emacs.

Are you on master? As far as I know, no fix has been applied there yet.

Also, if I understand correctly, the bug depends on ASLR both at the
time of dump and in the final Emacs image.

Also also, can you please stash copies of the emacs binaries and
emacs.pdmp that fail to work? I did something very silly and overwrote
my compiler with a very slightly different version (after carefully
backing up /usr/local/bin/gcc, too. Too bad that's just the driver
program), and now can no longer reproduce the issue easily.

> Perhaps the original change should be reverted until you've figured out
> how to fix this completely?  It's very annoying.

It is. I think it's worth the risk to push my original fix (reattached
to this message) now, but I don't have commit privileges so it's not
my decision to make. Alternatively, we could simply disable
purify-flag hash consing for now and everything should work, I think.

But I don't think there's a clear candidate for "the original change".
The bug's been with us for a while, possibly since pdumper was
introduced, but it got significantly worse when the recent byte
compilation changes were committed; however, those changes are
actually okay.

Is there anything I can do to help get this bug fixed on master? Thanks!
From 70419f630f60919c8645a10aeef8d299f5098ff5 Mon Sep 17 00:00:00 2001
From: Pip Cet <[email-masked]>
Date: Wed, 3 Jul 2019 11:48:22 +0000
Subject: [PATCH 2/2] Don't alter shared structure in dumped purecopied hash
 tables.

* src/fns.c (hash_table_rehash): Make sure we're operating on
fresh copies of ->next, ->index, ->hash.
---
 src/fns.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/fns.c b/src/fns.c
index 2fc000a7f4..44d2de523a 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4223,6 +4223,12 @@ hash_table_rehash (struct Lisp_Hash_Table *h)
 {
   ptrdiff_t size = HASH_TABLE_SIZE (h);
 
+  /* These structures may have been purecopied and shared
+     (bug#36447).  */
+  h->next = Fcopy_sequence (h->next);
+  h->index = Fcopy_sequence (h->index);
+  h->hash = Fcopy_sequence (h->hash);
+
   /* 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