From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: news-spam@referential.org.uk (Gareth Jones) Newsgroups: gmane.emacs.bugs Subject: pop3-read-response not robust in the presence of timers Date: 17 Apr 2003 14:19:14 +0100 Sender: bug-gnu-emacs-bounces+gnu-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: Reply-To: emacs-bug@referential.org.uk NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1050585895 15946 80.91.224.249 (17 Apr 2003 13:24:55 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 17 Apr 2003 13:24:55 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+gnu-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 17 15:24:52 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1969Nk-00048l-00 for ; Thu, 17 Apr 2003 15:24:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 1969Mz-0005SN-06 for gnu-bug-gnu-emacs@m.gmane.org; Thu, 17 Apr 2003 09:24:05 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 1969J3-0004WU-00 for bug-gnu-emacs@gnu.org; Thu, 17 Apr 2003 09:20:01 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 1969J0-0004UV-00 for bug-gnu-emacs@gnu.org; Thu, 17 Apr 2003 09:19:59 -0400 Original-Received: from serenity.mcc.ac.uk ([130.88.200.93]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 1969Ik-0004LK-00 for bug-gnu-emacs@gnu.org; Thu, 17 Apr 2003 09:19:42 -0400 Original-Received: from gwa3.wiau.man.ac.uk ([130.88.234.219]) by serenity.mcc.ac.uk with esmtp (Exim 4.14) id 1969IY-000Gyg-GK for bug-gnu-emacs@gnu.org; Thu, 17 Apr 2003 14:19:30 +0100 Original-To: bug-gnu-emacs@gnu.org Organisation: University of Manchester Original-Lines: 82 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 X-Spam-Score: -12.3 (------------) X-Scanner: exiscan for exim4 (http://duncanthrax.net/exiscan/) *1969IY-000Gyg-GK*E0UJt.0smlo* X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: bug-gnu-emacs-bounces+gnu-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:4830 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:4830 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 + + * pop3.el (pop3-retr, pop3-read-response): set buffer after + accept-process-output. + 2003-01-27 Juanma Barranquero * imap.el (imap-mailbox-status): Fix typo. Diff finished at Thu Apr 17 13:42:45