GNU bug report logs - #45944
28.0.50; Mailabbrev sometimes hangs

Previous Next

Package: emacs;

Reported by: Katsumi Yamaoka <yamaoka <at> jpl.org>

Date: Mon, 18 Jan 2021 00:12:01 UTC

Severity: normal

Tags: fixed

Found in version 28.0.50

Fixed in version 28.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 45944 in the body.
You can then email your comments to 45944 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#45944; Package emacs. (Mon, 18 Jan 2021 00:12:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Katsumi Yamaoka <yamaoka <at> jpl.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 18 Jan 2021 00:12:01 GMT) Full text and rfc822 format available.

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

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; Mailabbrev sometimes hangs
Date: Mon, 18 Jan 2021 09:10:31 +0900
Hi,

When expanding a mail abbrev in the message header of a message-
mode buffer, it sometime hangs like it goes into an infinite loop.
It's ok for Emacs on the Linux platform because I can break it by
C-g.  However, on Cygwin, only I can do is to kill Emacs, as C-g
doesn't break a Lisp infinite loop on Emacs built on that platform.

Though I haven't found out the cause of the problem so far, it seems
to happen when there are some kinds of contents in the message body,
and seems not to happen if the body is empty.  So, a workaround I'm
using now is as follows:

(defadvice abbrev--default-expand (around my-narrow-to-head activate)
  "Narrow the messge buffer to the headers when expanding an abbrev."
  (save-restriction
    (when (message-point-in-header-p)
      (let ((cur (point)))
        (message-narrow-to-headers)
        (goto-char cur)))
    ad-do-it))

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45944; Package emacs. (Mon, 18 Jan 2021 23:40:02 GMT) Full text and rfc822 format available.

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

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: 45944 <at> debbugs.gnu.org
Subject: Re: bug#45944: 28.0.50; Mailabbrev sometimes hangs
Date: Tue, 19 Jan 2021 08:39:00 +0900
On Mon, 18 Jan 2021 09:10:31 +0900, Katsumi Yamaoka wrote:
> When expanding a mail abbrev in the message header of a message-
> mode buffer, it sometime hangs like it goes into an infinite loop.
[...]
> Though I haven't found out the cause of the problem so far,...

I found it.  `(forward-word 1)' in the `abbrev--before-point'
function takes a very long time for a certain mail body contents
(`hang' I wrote first was my misregarding).
Here is a recipe to reproduce the problem in `emacs -Q':

1. Create the ~/.mailrc file, if it is absent.
   The file needs to contain at least a line like this:

--8<---------------cut here---------------start------------->8---
foo foo <at> example.com.invalid
--8<---------------cut here---------------end--------------->8---

2. Eval this form in the *scratch* buffer.

--8<---------------cut here---------------start------------->8---
(with-current-buffer (get-buffer-create "*testing*")
  (erase-buffer)
  (insert "To: \n--text follows this line--\n\
________________________________________________________________\n")
  (message-mode)
  (mail-abbrevs-setup)
  (goto-char (point-min))
  (end-of-line)
  (pop-to-buffer (current-buffer)))
--8<---------------cut here---------------end--------------->8---

3. In To: header, enter "foo" or something another and type ",".


As far as I can observe, the more "____" line is long, the more
it takes a long time.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45944; Package emacs. (Tue, 19 Jan 2021 04:48:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: 45944 <at> debbugs.gnu.org
Subject: Re: bug#45944: 28.0.50; Mailabbrev sometimes hangs
Date: Tue, 19 Jan 2021 05:47:20 +0100
Katsumi Yamaoka <yamaoka <at> jpl.org> writes:

> As far as I can observe, the more "____" line is long, the more
> it takes a long time.

Curious.  I can reproduce this with the example code, but the function
that's hanging is apparently just doing:

(re-search-forward (concat "^" mail-citation-prefix-regexp ".*$") nil t)

When I try this manually, then it doesn't hang, which is the curious
thing?  So why is it hanging from a syntax-propertize perspective but
not when called directly?

Debugger entered--Lisp error: (quit)
  search-forward-regexp("^\\([ \11]*\\(\\w\\|[_.]\\)+>+\\|[ \11]*[>|]\\)+.*$" 100 noerror)
  (while (search-forward-regexp citation-regexp end 'noerror) (let ((
  (let ((citation-regexp (concat "^" message-cite-prefix-regexp ".*$"
  message--syntax-propertize(1 100)
  syntax-propertize(100)
  internal--syntax-propertize(7)
  abbrev--before-point()

Anyway, this is the regexp in question:

(defcustom mail-citation-prefix-regexp
  (purecopy "\\([ \t]*\\(\\w\\|[_.]\\)+>+\\|[ \t]*[>|]\\)+")

And I guess there's some extreme backtracking going on with the

  \\(\\w\\|[_.]\\)+>

part?

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45944; Package emacs. (Tue, 19 Jan 2021 08:31:02 GMT) Full text and rfc822 format available.

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

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Katsumi Yamaoka <yamaoka <at> jpl.org>, 45944 <at> debbugs.gnu.org
Subject: Re: bug#45944: 28.0.50; Mailabbrev sometimes hangs
Date: Tue, 19 Jan 2021 09:30:18 +0100
On Jan 19 2021, Lars Ingebrigtsen wrote:

> And I guess there's some extreme backtracking going on with the
>
>   \\(\\w\\|[_.]\\)+>
>
> part?

Does `\w' match `_'?

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45944; Package emacs. (Tue, 19 Jan 2021 11:08:01 GMT) Full text and rfc822 format available.

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

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: schwab <at> linux-m68k.org
Cc: larsi <at> gnus.org, 45944 <at> debbugs.gnu.org
Subject: Re: bug#45944: 28.0.50; Mailabbrev sometimes hangs
Date: Tue, 19 Jan 2021 20:07:36 +0900
Andreas Schwab <schwab <at> linux-m68k.org> wrote:
> On Jan 19 2021, Lars Ingebrigtsen wrote:
>> And I guess there's some extreme backtracking going on with the
>>   \\(\\w\\|[_.]\\)+>
>> part?
> Does `\w' match `_'?

Yes it does.  While the hang arises, syntax table is overridden
temporarily with `mail-abbrev-syntax-table'.

(mail-abbrev-make-syntax-table)
(with-syntax-table mail-abbrev-syntax-table
  (string-match "\\w" "_"))

So, it explains some strange things, doesn't it?  Actually, this
advice looks to solve the problem:

(defadvice message--syntax-propertize (around use-standard-syntax-table
                                              activate)
  "Use standard-syntax-table."
  (with-syntax-table (standard-syntax-table)
    ad-do-it))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45944; Package emacs. (Tue, 19 Jan 2021 15:10:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: schwab <at> linux-m68k.org, 45944 <at> debbugs.gnu.org
Subject: Re: bug#45944: 28.0.50; Mailabbrev sometimes hangs
Date: Tue, 19 Jan 2021 16:09:28 +0100
Katsumi Yamaoka <yamaoka <at> jpl.org> writes:

> Yes it does.  While the hang arises, syntax table is overridden
> temporarily with `mail-abbrev-syntax-table'.
>
> (mail-abbrev-make-syntax-table)
> (with-syntax-table mail-abbrev-syntax-table
>   (string-match "\\w" "_"))
>
> So, it explains some strange things, doesn't it?  Actually, this
> advice looks to solve the problem:
>
> (defadvice message--syntax-propertize (around use-standard-syntax-table
>                                               activate)
>   "Use standard-syntax-table."
>   (with-syntax-table (standard-syntax-table)
>     ad-do-it))

I've now changed the function along these lines -- it now starts with

(defun message--syntax-propertize (beg end)
  "Syntax-propertize certain message text specially."
  (with-syntax-table message-mode-syntax-table

and this seems to fix the reported test case.

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




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 19 Jan 2021 15:10:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 45944 <at> debbugs.gnu.org and Katsumi Yamaoka <yamaoka <at> jpl.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 19 Jan 2021 15:10:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45944; Package emacs. (Tue, 19 Jan 2021 21:51:02 GMT) Full text and rfc822 format available.

Message #27 received at 45944-done <at> debbugs.gnu.org (full text, mbox):

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: schwab <at> linux-m68k.org, 45944-done <at> debbugs.gnu.org
Subject: Re: bug#45944: 28.0.50; Mailabbrev sometimes hangs
Date: Wed, 20 Jan 2021 06:50:15 +0900
On Tue, 19 Jan 2021 16:09:28 +0100, Lars Ingebrigtsen wrote:
> I've now changed the function along these lines -- it now starts with

> (defun message--syntax-propertize (beg end)
>   "Syntax-propertize certain message text specially."
>   (with-syntax-table message-mode-syntax-table

> and this seems to fix the reported test case.

Good!  This fixes the problem that arises when manipulating the
header of a reply message to the actual email I first found it.
Thanks.  Closing.




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

This bug report was last modified 3 years and 67 days ago.

Previous Next


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