GNU bug report logs - #48379
27.2; ispell-init-process may be called recursively during sit-for

Previous Next

Package: emacs;

Reported by: miha <at> kamnitnik.top

Date: Wed, 12 May 2021 14:14:02 UTC

Severity: normal

Found in version 27.2

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 48379 in the body.
You can then email your comments to 48379 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#48379; Package emacs. (Wed, 12 May 2021 14:14:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to miha <at> kamnitnik.top:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 12 May 2021 14:14:02 GMT) Full text and rfc822 format available.

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

From: miha <at> kamnitnik.top
To: bug-gnu-emacs <at> gnu.org
Subject: 27.2; ispell-init-process may be called recursively during sit-for
Date: Wed, 12 May 2021 16:14:07 +0200
[Message part 1 (text/plain, inline)]
In ispell-init-process, sit-for can accept process output, which may in
turn call ispell-init-process again, recursively. If needed, I can post
a short reproducer.

This recursive call results in the following sequence of events:

    (ispell-kill-ispell t)
    (ispell-kill-ispell t)
    (setq ispell-process (ispell-start-process))
    (setq ispell-process (ispell-start-process))

where the middle two calls happen recursively from within sit-for. As
you can see, this creates one extra useless ispell process.

The following simple patch fixes this by moving the killing of the
process closer to starting of the new process without sit-for in the
middle

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 4dbc7640bc..80ddb4861f 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -2865,8 +2865,6 @@ ispell-init-process
 	     (or (or ispell-local-pdict ispell-personal-dictionary)
 		 (equal ispell-process-directory default-directory)))
 	(setq ispell-filter nil ispell-filter-continue nil)
-      ;; may need to restart to select new personal dictionary.
-      (ispell-kill-ispell t)
       (let ((reporter
              (make-progress-reporter
               (format "Starting new Ispell process %s with %s dictionary..."
@@ -2874,6 +2872,8 @@ ispell-init-process
 	              (or ispell-local-dictionary ispell-dictionary
                           "default")))))
         (sit-for 0)
+        ;; May need to restart to select new personal dictionary.
+        (ispell-kill-ispell t)
         (setq ispell-library-directory (ispell-check-version)
               ;; Assign a non-nil value to ispell-process-directory
               ;; before calling ispell-start-process, since that

Best regards.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48379; Package emacs. (Wed, 12 May 2021 19:51:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: miha <at> kamnitnik.top
Cc: 48379 <at> debbugs.gnu.org
Subject: Re: bug#48379: 27.2; ispell-init-process may be called recursively
 during sit-for
Date: Wed, 12 May 2021 21:50:18 +0200
miha <at> kamnitnik.top writes:

> In ispell-init-process, sit-for can accept process output, which may in
> turn call ispell-init-process again, recursively. If needed, I can post
> a short reproducer.

Yes, a reproducer would be nice to have here.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48379; Package emacs. (Fri, 14 May 2021 13:10:02 GMT) Full text and rfc822 format available.

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

From: <miha <at> kamnitnik.top>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 48379 <at> debbugs.gnu.org
Subject: Re: bug#48379: 27.2; ispell-init-process may be called recursively
 during sit-for
Date: Fri, 14 May 2021 15:09:24 +0200
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> miha <at> kamnitnik.top writes:
>
>> In ispell-init-process, sit-for can accept process output, which may in
>> turn call ispell-init-process again, recursively. If needed, I can post
>> a short reproducer.
>
> Yes, a reproducer would be nice to have here.

My original problem was kind of complex:
Install magit and guess-language.el,
change ispell default dictionary to a non-English language,
hook flyspell-mode and guess-language to text-mode,
each M-x magit-commit-create would leave a spurious aspell process.

So as I was coming up with a shorter reproducer, I found out that the
problem was an idle timer from guess-language, accidentally hijacking
itself into ispell's sit-for. I no longer believe this problem to be
ispell's and will send a report to guess-language.

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

Best regards.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48379; Package emacs. (Sun, 16 May 2021 14:08:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: <miha <at> kamnitnik.top>
Cc: 48379 <at> debbugs.gnu.org
Subject: Re: bug#48379: 27.2; ispell-init-process may be called recursively
 during sit-for
Date: Sun, 16 May 2021 16:06:58 +0200
<miha <at> kamnitnik.top> writes:

> So as I was coming up with a shorter reproducer, I found out that the
> problem was an idle timer from guess-language, accidentally hijacking
> itself into ispell's sit-for. I no longer believe this problem to be
> ispell's and will send a report to guess-language.

Ah, I see.  :-)  Thanks for checking; I'm closing this bug report here,
then.

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




bug closed, send any further explanations to 48379 <at> debbugs.gnu.org and miha <at> kamnitnik.top Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 16 May 2021 14:08:12 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 14 Jun 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 1 day ago.

Previous Next


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