GNU bug report logs - #53343
29.0.50; assertion failure in diff--iterate-hunks

Previous Next

Package: emacs;

Reported by: Stephen Berman <stephen.berman <at> gmx.net>

Date: Tue, 18 Jan 2022 11:04:01 UTC

Severity: normal

Found in version 29.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 53343 in the body.
You can then email your comments to 53343 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#53343; Package emacs. (Tue, 18 Jan 2022 11:04:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stephen Berman <stephen.berman <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 18 Jan 2022 11:04:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; assertion failure in diff--iterate-hunks
Date: Tue, 18 Jan 2022 12:02:17 +0100
Trying to view in Gnus an attached and buttonized diff in a certain
article raises an assertion failure.  To reproduce:

0. emacs -Q
1. M-x gnus
2. Type `y' at prompt
3. Type `B RET news.gmane.io RET'
4. Type `C-s gmane.emacs.bugs RET RET'
5. Type `1 RET' at prompt
6. Type `j' and enter `<87fspm0z47.fsf <at> stranik.org> RET' at the prompt
7. Click on the Options menu and check "Enter Debugger on Error"
8. Type `2 b'
=>
Debugger entered--Lisp error: (cl-assertion-failed ((looking-at diff-hunk-header-re) nil))
  cl--assertion-failed((looking-at diff-hunk-header-re))
  diff--iterate-hunks(975 #f(compiled-function (beg end) #<bytecode 0x55bd99118e1ddef>))
  diff--font-lock-syntax(975)
  font-lock-fontify-keywords-region(1 975 nil)
  font-lock-default-fontify-region(1 975 nil)
  font-lock-fontify-region(1 975)
  #f(compiled-function (beg end) #<bytecode -0x177a72732a745bc7>)(1 975)
  font-lock-ensure()
  mm-display-inline-fontify((#<buffer  *mm*-927541> ("text/x-diff") nil nil ("attachment" (filename . "ebrowse-emacs-27.2-fix.diff")) nil nil nil) diff-mode)
  mm-display-patch-inline((#<buffer  *mm*-927541> ("text/x-diff") nil nil ("attachment" (filename . "ebrowse-emacs-27.2-fix.diff")) nil nil nil))
  mm-display-inline((#<buffer  *mm*-927541> ("text/x-diff") nil nil ("attachment" (filename . "ebrowse-emacs-27.2-fix.diff")) nil nil nil))
  gnus-mm-display-part((#<buffer  *mm*-927541> ("text/x-diff") nil nil ("attachment" (filename . "ebrowse-emacs-27.2-fix.diff")) nil nil nil))
  gnus-article-view-part(2)
  funcall-interactively(gnus-article-view-part 2)
  call-interactively(gnus-article-view-part nil nil)
  command-execute(gnus-article-view-part)

The assertion fails when point is at the beginning of the last line in
the following excerpt from the diff (in buffer " *temp*")

  *** /var/home/janstranik/src/emacs-27.2/lib-src/ebrowse.c~	2021-01-28 11:52:16.000000000 -0600
  --- /var/home/janstranik/src/emacs-27.2/lib-src/ebrowse.c	2021-09-24 09:31:49.136287028 -0500
  ***************
  *** 1924,1931 ****

This happens because diff-beginning-of-hunk calls re-search-forward on
diff-hunk-header-re, which puts point at the end the line "*** 1924,1931
****" and then calls (forward-line 0), putting point at the beginning of
that line.  But then (looking-at diff-hunk-header-re) returns nil,
raising the assertion in diff--iterate-hunks.  Replacing (forward-line
0) in diff-beginning-of-hunk with (forward-line -1) makes the assertion
succeed.

I'm not sure if this is a bug or if the diff is malformed.  But evidence
that the diff is not malformed is that if the diff in the article is
saved to a file (by typing `2 K o' in the *Summary* buffer), then
visiting that file in diff-mode with -Q does not raise an assertion
failure.


In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.31, cairo version 1.17.4)
 of 2022-01-18 built on strobelfs2
Repository revision: 68472c12e7acdb6e9f55a10eecf02a4ace26465a
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Linux From Scratch r11.0-115

Configured using:
 'configure --with-xwidgets 'CFLAGS=-Og -g3'
 PKG_CONFIG_PATH=/opt/qt5/lib/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM
XPM XWIDGETS GTK3 ZLIB




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53343; Package emacs. (Tue, 18 Jan 2022 12:21:01 GMT) Full text and rfc822 format available.

Message #8 received at 53343 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: 53343 <at> debbugs.gnu.org
Subject: Re: bug#53343: 29.0.50; assertion failure in diff--iterate-hunks
Date: Tue, 18 Jan 2022 13:20:18 +0100
On Tue, 18 Jan 2022 12:02:17 +0100 Stephen Berman <stephen.berman <at> gmx.net> wrote:

> Trying to view in Gnus an attached and buttonized diff in a certain
> article raises an assertion failure.  To reproduce:
>
> 0. emacs -Q
> 1. M-x gnus
> 2. Type `y' at prompt
> 3. Type `B RET news.gmane.io RET'
> 4. Type `C-s gmane.emacs.bugs RET RET'
> 5. Type `1 RET' at prompt
> 6. Type `j' and enter `<87fspm0z47.fsf <at> stranik.org> RET' at the prompt
> 7. Click on the Options menu and check "Enter Debugger on Error"
> 8. Type `2 b'
> =>
> Debugger entered--Lisp error: (cl-assertion-failed ((looking-at diff-hunk-header-re) nil))
[...]
> The assertion fails when point is at the beginning of the last line in
> the following excerpt from the diff (in buffer " *temp*")
>
>   *** /var/home/janstranik/src/emacs-27.2/lib-src/ebrowse.c~	2021-01-28 11:52:16.000000000 -0600
>   --- /var/home/janstranik/src/emacs-27.2/lib-src/ebrowse.c	2021-09-24 09:31:49.136287028 -0500
>   ***************
>   *** 1924,1931 ****
>
> This happens because diff-beginning-of-hunk calls re-search-forward on
> diff-hunk-header-re, which puts point at the end the line "*** 1924,1931
> ****" and then calls (forward-line 0), putting point at the beginning of
> that line.  But then (looking-at diff-hunk-header-re) returns nil,
> raising the assertion in diff--iterate-hunks.  Replacing (forward-line
> 0) in diff-beginning-of-hunk with (forward-line -1) makes the assertion
> succeed.
>
> I'm not sure if this is a bug or if the diff is malformed.  But evidence
> that the diff is not malformed is that if the diff in the article is
> saved to a file (by typing `2 K o' in the *Summary* buffer), then
> visiting that file in diff-mode with -Q does not raise an assertion
> failure.

On the other hand, I get the assertion failure with the above recipe in
emacs-28 and emacs-27, and it seems unlikely that such a bug in
diff-mode would have gone unnoticed till now, so maybe the diff is
malformed.  (Though if so, why does the failure not happen when visiting
the file containing the diff?)

Steve Berman




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53343; Package emacs. (Fri, 21 Jan 2022 11:09:02 GMT) Full text and rfc822 format available.

Message #11 received at 53343 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: 53343 <at> debbugs.gnu.org
Subject: Re: bug#53343: 29.0.50; assertion failure in diff--iterate-hunks
Date: Fri, 21 Jan 2022 12:07:49 +0100
Stephen Berman <stephen.berman <at> gmx.net> writes:

> On the other hand, I get the assertion failure with the above recipe in
> emacs-28 and emacs-27, and it seems unlikely that such a bug in
> diff-mode would have gone unnoticed till now, so maybe the diff is
> malformed.  (Though if so, why does the failure not happen when visiting
> the file containing the diff?)

I tried

(setq debug-on-error t)

put the diff in a file, and got a backtrace when loading it.

Debugger entered--Lisp error: (error "Unknown diff hunk type")
  signal(error ("Unknown diff hunk type"))
  error("Unknown diff hunk type")
  diff-hunk-text("" nil nil)
  diff-syntax-fontify-hunk(506 506 t)
etc

So I've now made that function less assertative, and that fixes this
issue.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 53343 <at> debbugs.gnu.org and Stephen Berman <stephen.berman <at> gmx.net> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 21 Jan 2022 11:09:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53343; Package emacs. (Fri, 21 Jan 2022 13:30:03 GMT) Full text and rfc822 format available.

Message #16 received at 53343 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 53343 <at> debbugs.gnu.org
Subject: Re: bug#53343: 29.0.50; assertion failure in diff--iterate-hunks
Date: Fri, 21 Jan 2022 14:29:21 +0100
On Fri, 21 Jan 2022 12:07:49 +0100 Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> Stephen Berman <stephen.berman <at> gmx.net> writes:
>
>> On the other hand, I get the assertion failure with the above recipe in
>> emacs-28 and emacs-27, and it seems unlikely that such a bug in
>> diff-mode would have gone unnoticed till now, so maybe the diff is
>> malformed.  (Though if so, why does the failure not happen when visiting
>> the file containing the diff?)
>
> I tried
>
> (setq debug-on-error t)
>
> put the diff in a file, and got a backtrace when loading it.
>
> Debugger entered--Lisp error: (error "Unknown diff hunk type")
>   signal(error ("Unknown diff hunk type"))
>   error("Unknown diff hunk type")
>   diff-hunk-text("" nil nil)
>   diff-syntax-fontify-hunk(506 506 t)
> etc

Yes, I get this too.  I must have mistested that before.

> So I've now made that function less assertative, and that fixes this
> issue.

Thanks, and I confirm your fix avoids the error.  However, you added
this to the doc string of `diff-ignore-whitespace-hunk': "If
INHIBIT-ERROR, ignore malformed hunks."  But you didn't add an
INHIBIT-ERROR argument.

Steve Berman




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53343; Package emacs. (Fri, 21 Jan 2022 13:33:01 GMT) Full text and rfc822 format available.

Message #19 received at 53343 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: 53343 <at> debbugs.gnu.org
Subject: Re: bug#53343: 29.0.50; assertion failure in diff--iterate-hunks
Date: Fri, 21 Jan 2022 14:31:47 +0100
Stephen Berman <stephen.berman <at> gmx.net> writes:

> Thanks, and I confirm your fix avoids the error.  However, you added
> this to the doc string of `diff-ignore-whitespace-hunk': "If
> INHIBIT-ERROR, ignore malformed hunks."  But you didn't add an
> INHIBIT-ERROR argument.

😀  Forgot to remove that after deciding that I didn't need to add any
arguments after all.  Now fixed.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 19 Feb 2022 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 38 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.