bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pop3-read-response not robust in the presence of timers


From: Gareth Jones
Subject: pop3-read-response not robust in the presence of timers
Date: 17 Apr 2003 14:19:14 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

In GNU Emacs 21.3.2 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2003-04-03 on gwa3

Emacs occasionally hangs for ever in such a way that C-g does not
interrupt it when retrieving email using Gnus running on a timer.  I
have observed this when fetching mail using gnus-demon to check for
new mail every few minutes.  I suspect that being run from a timer is
important because (i) the circumstances that cause the bug do not
occur often so running it repeatedly makes it more likely that the bug
will be noticed and (ii) it seems that timers are run with
inhibit-quit set to t (this does not seem to be documented, at least
not in the Timers page of the elisp manual).

gdb reveals that when this happens Emacs is stuck in the while loop in
`pop3-read-response' (pop3.el:176):

    ...
    (save-excursion
      (set-buffer (process-buffer process))
      (goto-char pop3-read-point)
      (while (not (search-forward "\r\n" nil t))
        (accept-process-output process 3)
        (goto-char pop3-read-point))
       ...
       )
     ...

and that `current-buffer' is not (process-buffer process) but a
completely unrelated buffer.  I suspect that what is happening is that
during the call to `accept-process-output' a timer is sometimes run
that changes the current buffer.

The following patch restores the current buffer after
accept-process-output, but given the intermittent nature of the bug it
is hard to be absolutely certain that this has solved the problem.
This problem may be more wide-spread than just in pop3.el.  But I have
definitely encountered it in `pop3-read-response' and I assume that
`pop3-retr' could also have problems (so the patch applies the same
fix to that).

Gareth Jones


cd /usr/local/share/emacs/21.3/lisp/gnus/
diff -u /usr/local/share/emacs/21.3/lisp/gnus/pop3.el\~ 
/usr/local/share/emacs/21.3/lisp/gnus/pop3.el
--- /usr/local/share/emacs/21.3/lisp/gnus/pop3.el~      Wed Jun 12 18:32:52 2002
+++ /usr/local/share/emacs/21.3/lisp/gnus/pop3.el       Thu Apr 17 13:17:42 2003
@@ -175,6 +175,9 @@
       (goto-char pop3-read-point)
       (while (not (search-forward "\r\n" nil t))
        (accept-process-output process 3)
+       ;; A timer called while we waited for process input could have
+       ;; changed the current buffer.
+       (set-buffer (process-buffer process))
        (goto-char pop3-read-point))
       (setq match-end (point))
       (goto-char pop3-read-point)
@@ -360,6 +363,9 @@
       (set-buffer (process-buffer process))
       (while (not (re-search-forward "^\\.\r\n" nil t))
        (accept-process-output process 3)
+       ;; A timer called while we waited for process input could have
+       ;; changed the current buffer.
+       (set-buffer (process-buffer process))
        ;; bill@att.com ... to save wear and tear on the heap
        ;; uncommented because the condensed version below is a problem for
        ;; some.

diff -u /usr/local/share/emacs/21.3/lisp/gnus/ChangeLog\~ 
/usr/local/share/emacs/21.3/lisp/gnus/ChangeLog
--- /usr/local/share/emacs/21.3/lisp/gnus/ChangeLog~    Wed Jan 29 08:12:35 2003
+++ /usr/local/share/emacs/21.3/lisp/gnus/ChangeLog     Thu Apr 17 13:42:34 2003
@@ -1,3 +1,8 @@
+2003-04-17  Gareth Jones  <emacs-bug@referential.org.uk>
+
+       * pop3.el (pop3-retr, pop3-read-response): set buffer after
+       accept-process-output.
+
 2003-01-27  Juanma Barranquero  <lektu@terra.es>
 
        * imap.el (imap-mailbox-status): Fix typo.

Diff finished at Thu Apr 17 13:42:45





reply via email to

[Prev in Thread] Current Thread [Next in Thread]