all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: 33083@debbugs.gnu.org
Subject: bug#33083: 27.0.50; Bignums and message-checksum
Date: Thu, 18 Oct 2018 10:55:36 -0400	[thread overview]
Message-ID: <jwvefcnb8yf.fsf@iro.umontreal.ca> (raw)

Package: Emacs
Version: 27.0.50

I just got this error:

    Debugger entered--Lisp error: (overflow-error)
      ash(100.....0170 1)
      message-checksum()
      message--yank-original-internal(nil)
      (let nil (message--yank-original-internal 'nil))
      eval((let nil (message--yank-original-internal 'nil)))
      message-yank-original()
      [...]
      command-execute(gnus-summary-followup-with-original)

Where the "....." is fairly long.  The problem is simple:
In message-checksum we do

      (while (not (eobp))
	(when (not (looking-at "[ \t\n]"))
	  (setq sum (logxor (ash sum 1) (if (natnump sum) 0 1)
			    (char-after))))
	(forward-char 1)))

where the code assumes an `ash` where the MSB bit would overflow into
the sign bit when the result can't fit in a fixnum, and the (if (natnump
sum) 0 1) ends up feeding that sign bit back to the LSB, thus doing
a "rotate".

Of course, with bignums we don't overflow until we reach the 65536 bits
and when we do, we signal an error instead of dropping the extra bits.

So the above error is signaled when the yanked text is longer than 20Kchars
(or non-whitespace chars).  Note that even before we reach this error,
we have another problem: this function is basically used at one spot
where we do

      (not (eq (message-checksum) message-checksum))

and if the checksum is larger than a fixnum, then this `eq` will always
return false even if both numbers are equal.

So, ever since we switched to bignums, this equality is basically always
false (except when yanking less 8 non-whitespace chars).

What should we do:
- just get rid of this message-checksum feature (which has been broken
  in master for a few months now).
- replace message-checksum with something like md5 (which will be faster
  but won't ignore whitespace chars like the current code does).
- try to get back the original semantics (e.g. by introducing a proper
  bit-rotate primitive).


        Stefan





             reply	other threads:[~2018-10-18 14:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-18 14:55 Stefan Monnier [this message]
2018-12-26  9:17 ` bug#33083: 27.0.50; Bignums and message-checksum 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=jwvefcnb8yf.fsf@iro.umontreal.ca \
    --to=monnier@iro.umontreal.ca \
    --cc=33083@debbugs.gnu.org \
    /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.