unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5924: 23.1; accept-process-output switching current-buffer
@ 2010-04-10 21:23 Uday S Reddy
  2010-04-11  2:54 ` Stefan Monnier
  0 siblings, 1 reply; 12+ messages in thread
From: Uday S Reddy @ 2010-04-10 21:23 UTC (permalink / raw)
  To: 5924; +Cc: U.S.Reddy

Reading the elisp manual doesn't indicate anywhere that a call such as 

   (accept-process-output process)

should change the current-buffer.  But it is happening.  It led to
some hairy asynchronous errors that took me an entire week to track
down.  Finally, I found an instance that was sort of reproducible, and
tested it with a code fragment such as this:

   (let ((wait nil) (buffer-x (current-buffer)))
     ...
     (if (not (equal (current-buffer) buffer-x))
        (debug nil wait))
     (setq wait t)
     (accept-process-output process)
     (if (not (equal (current-buffer) buffer-x))
        (debug nil wait))
     (setq wait nil)
     ...
   )

If the debugger is entered with the argument 't' that means that the
call to accept-process-output changed the 'current-buffer'.  The
following backtrace was obtained:

Debugger entered: (t)
  vm-imap-read-object(#<process IMAP<1>> t)
  vm-imap-read-object(#<process IMAP<1>>)
  vm-imap-read-response(#<process IMAP<1>>)
  vm-imap-read-response-and-verify(#<process IMAP<1>> "FLAGS FETCH")
  vm-imap-get-message-data-list(#<process IMAP<1>> 1 3672)
  vm-imap-retrieve-uid-and-flags-data()
  vm-imap-get-synchronization-data(t)
  vm-imap-synchronize-folder(t nil t t t t)
  vm-get-spooled-mail(t)
  vm-get-new-mail(nil)
  call-interactively(vm-get-new-mail nil nil)

The full file containing the code, VM's IMAP client, is attached.
The misbehaving accept-process-output call is in the
vm-imap-read-object function.

My theory of what happened here is as follows: VM ended an existing
IMAP session (#<process IMAP>) by sending a LOGOUT command, and
created a new one (#<process IMAP<1>>).  While it was working with the
second session, in the process-buffer, the server must have sent back
some response to the first session, which would have been accepted
during a call to accept-process-output.  This caused the
current-buffer to change to the process-buffer of the original
session. 

I found the problem orignally in Emacs 22.2, but checking it with 23.1
shows that the problem is still present in the current version.

Cheers,
Uday

-----

In GNU Emacs 23.1.1 (i386-mingw-nt5.1.2600)
 of 2009-07-30 on SOFT-MJASON
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.4)'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: C.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t

Major mode: VM Summary

Minor modes in effect:
  savehist-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-encryption-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<return> g C-p C-p C-SPC C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-x C-k C-x C-f d : / g n u SPC 
v m SPC t r u SPC / SPC e m SPC <backspace> <backspace> 
b u SPC SPC SPC SPC <backspace> - e m a c s 2 3 . t 
x t <return> C-y C-x , C-x C-s <help-echo> <down-mouse-1> 
<mouse-1> C-h i m e l SPC <return> SPC C-s p r o c 
e s s C-a m <return> SPC m o u t p u t SPC SPC <return> 
<down-mouse-1> <mouse-1> <wheel-down> <wheel-down> 
<double-wheel-down> <help-echo> <down-mouse-1> <mouse-1> 
<down-mouse-2> <mouse-2> <down-mouse-1> <mouse-1> <wheel-down> 
<wheel-down> <wheel-down> <down-mouse-1> <mouse-1> 
<wheel-up> <double-wheel-up> <wheel-down> <wheel-up> 
<wheel-up> <wheel-down> <wheel-down> <wheel-down> <wheel-up> 
<double-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <down-mouse-1> <mouse-1> <wheel-down> 
<double-wheel-down> <wheel-up> <double-wheel-up> <triple-wheel-up> 
<wheel-up> <double-wheel-up> <triple-wheel-up> <down-mouse-1> 
<mouse-1> C-x b <return> q C-x , q C-x u C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-k C-x C-s C-x 
b * B SPC <return> q C-x m C-x k <return> M-x v m <backspace> 
<backspace> r e p o r t - e m SPC SPC <return>

Recent messages:
Composing main Info directory...done
Mark saved where search started
Mark set
Undo!
Saving file d:/gnu/vm/trunk/bug-accept-process-output-emacs23.txt...
Wrote d:/gnu/vm/trunk/bug-accept-process-output-emacs23.txt
Back to top level.
Parsing d:/Home/udr/.mailrc...
Parsing y:/dotfiles/.mailrc... done
Parsing d:/Home/udr/.mailrc... done

------

[ATTACHMENT d:/gnu/vm/trunk23/lisp/vm-imap.el, text/plain]







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

end of thread, other threads:[~2011-09-18 20:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-10 21:23 bug#5924: 23.1; accept-process-output switching current-buffer Uday S Reddy
2010-04-11  2:54 ` Stefan Monnier
2010-04-11 12:22   ` Uday S Reddy
2010-04-11 16:30     ` Stefan Monnier
2010-04-12 19:13       ` Uday S Reddy
2010-04-12 20:58         ` Stefan Monnier
2010-04-12 19:39       ` Uday S Reddy
2010-05-20  9:50       ` Uday S Reddy
2010-05-24  0:07       ` Uday S Reddy
2010-05-24  2:04       ` Uday S Reddy
2010-07-23 22:36         ` Stefan Monnier
2011-09-18 20:16           ` Lars Magne 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).