unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: news-spam@referential.org.uk (Gareth Jones)
Subject: pop3-read-response not robust in the presence of timers
Date: 17 Apr 2003 14:19:14 +0100	[thread overview]
Message-ID: <quistdjm7h.fsf@stud.man.ac.uk> (raw)

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	other threads:[~2003-04-17 13:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=quistdjm7h.fsf@stud.man.ac.uk \
    --to=news-spam@referential.org.uk \
    --cc=emacs-bug@referential.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).