all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 39529-done@debbugs.gnu.org, federicotedin@gmail.com
Subject: bug#39529: 28.0.50; Metahelp does not contain help text
Date: Sat, 15 Feb 2020 15:25:44 -0800	[thread overview]
Message-ID: <e1dae7d6-376c-a9f5-b0b6-4ade20dca59b@cs.ucla.edu> (raw)
In-Reply-To: <83blq7d06n.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 559 bytes --]

On 2/9/20 11:34 AM, Eli Zaretskii wrote:

> I suspect the sxhash changes on Jan 7.  This problem started happening
> in that day's build.

Right you are. The problem was Emacs was using a hash table to unify identical 
Lisp compiled objects when purecopying them, even though their doc strings were 
not set up yet (and so were 0 placeholders that always compared equal). Formerly 
this bug was masked because sxhash simply returned the objects' hashed 
addresses, but the January 7 changes unveiled the bug. I install the attached 
patch to fix the problem.

[-- Attachment #2: 0001-Fix-C-h-C-h-bug-due-to-mutating-a-hash-key.patch --]
[-- Type: text/x-patch, Size: 2051 bytes --]

From 3480071dfab30eaca7f1d014600b864d2ea22f62 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 15 Feb 2020 15:12:34 -0800
Subject: [PATCH] Fix C-h C-h bug due to mutating a hash key
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Federico Tedin (Bug#39529).
The problem was that dumping uses a hash table based on 'equal'
when purecopying compiled objects, but then modifies the compiled
objects while they are keys in the table.  This no-no was uncovered
by the sxhash fixes in 2020-01-07T19:23:11Z!eggert@cs.ucla.edu.
Eli Zaretski pinpointed the patch that triggered the bug.
* src/lread.c (read1): When reading a compiled object, replace
its docstring with a unique negative integer instead of with 0,
so that purecopy doesn’t unify it with some other compiled object
that happens to have the same Lisp code.
---
 src/lread.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/lread.c b/src/lread.c
index c124d5a1d8..f39e81ae2c 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2974,6 +2974,21 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
 	  vec = XVECTOR (tmp);
 	  if (vec->header.size == 0)
 	    invalid_syntax ("Empty byte-code object");
+
+	  if (COMPILED_DOC_STRING < vec->header.size
+	      && AREF (tmp, COMPILED_DOC_STRING) == make_fixnum (0))
+	    {
+	      /* read_list found a docstring like '(#$ . 5521)' and treated it
+		 as 0.  This placeholder 0 would lead to accidental sharing in
+		 purecopy's hash-consing, so replace it with a (hopefully)
+		 unique integer placeholder, which is negative so that it is
+		 not confused with a DOC file offset.  Eventually
+		 Snarf-documentation should replace the placeholder with the
+		 actual docstring.  */
+	      EMACS_UINT hash = XHASH (tmp) | (INTMASK - INTMASK / 2);
+	      ASET (tmp, COMPILED_DOC_STRING, make_ufixnum (hash));
+	    }
+
 	  make_byte_code (vec);
 	  return tmp;
 	}
-- 
2.17.1


  reply	other threads:[~2020-02-15 23:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-09 19:06 bug#39529: 28.0.50; Metahelp does not contain help text Federico Tedin
2020-02-09 19:22 ` Eli Zaretskii
2020-02-09 19:34   ` Eli Zaretskii
2020-02-15 23:25     ` Paul Eggert [this message]
2020-02-16 15:35       ` Eli Zaretskii
2020-02-16 16:51       ` Pip Cet
2020-02-16 19:43         ` Paul Eggert
2020-02-18 19:56           ` Pip Cet
2020-02-19  1:21             ` Paul Eggert
2020-02-19  2:34               ` Pip Cet
2020-02-19  9:00                 ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e1dae7d6-376c-a9f5-b0b6-4ade20dca59b@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=39529-done@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=federicotedin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.