unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#48379: 27.2; ispell-init-process may be called recursively during sit-for
@ 2021-05-12 14:14 miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-05-12 19:50 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-05-12 14:14 UTC (permalink / raw)
  To: 48379

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


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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#48379: 27.2; ispell-init-process may be called recursively during sit-for
  2021-05-12 14:14 bug#48379: 27.2; ispell-init-process may be called recursively during sit-for miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-05-12 19:50 ` Lars Ingebrigtsen
  2021-05-14 13:09   ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-12 19:50 UTC (permalink / raw)
  To: miha; +Cc: 48379

miha@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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#48379: 27.2; ispell-init-process may be called recursively during sit-for
  2021-05-12 19:50 ` Lars Ingebrigtsen
@ 2021-05-14 13:09   ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-05-16 14:06     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-05-14 13:09 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 48379

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

Lars Ingebrigtsen <larsi@gnus.org> writes:

> miha@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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#48379: 27.2; ispell-init-process may be called recursively during sit-for
  2021-05-14 13:09   ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-05-16 14:06     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-16 14:06 UTC (permalink / raw)
  To: miha; +Cc: 48379

<miha@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





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-16 14:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12 14:14 bug#48379: 27.2; ispell-init-process may be called recursively during sit-for miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-12 19:50 ` Lars Ingebrigtsen
2021-05-14 13:09   ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-16 14:06     ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).