* 23.0.50; `read-event' changes `current-buffer'
@ 2007-11-03 5:30 David Hansen
2007-11-03 17:14 ` Johan Bockgård
0 siblings, 1 reply; 3+ messages in thread
From: David Hansen @ 2007-11-03 5:30 UTC (permalink / raw)
To: emacs-pretest-bug
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.
Your bug report will be posted to the emacs-pretest-bug@gnu.org mailing list.
Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:
Hello,
to reproduce:
$ emacs -Q
M-x eshell RET
$ while #'(lambda () t) { echo XXX; sleep 1}
C-x b *scratch* RET
(with-temp-buffer
(let ((buf (current-buffer)))
(read-event nil nil 3)
(format ":%s: :%s:" (buffer-name buf) (current-buffer))))
C-u C-x C-e
": *temp*: :*eshell*:"
David
If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
`bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/home/dhansen/share/emacs/23.0.50/etc/DEBUG for instructions.
In GNU Emacs 23.0.50.1 (i686-pc-linux-gnu)
of 2007-10-28 on robotron
Windowing system distributor `The X.Org Foundation', version 11.0.10400000
configured using `configure '--prefix=/home/dhansen' '--disable-sound' '--disable-pop' '--with-x-toolkit=no''
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: en_US.UTF-8
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8
default-enable-multibyte-characters: t
Major mode: EShell
Minor modes in effect:
TeX-PDF-mode: t
jabber-activity-mode: t
which-function-mode: t
show-paren-mode: t
iswitchb-mode: t
tooltip-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
unify-8859-on-encoding-mode: t
utf-translate-cjk-mode: t
auto-compression-mode: t
line-number-mode: t
abbrev-mode: 1
Recent input:
<switch-frame> M-x g n u s <return> y C-n C-n C-n C-n
C-n M-g <switch-frame> <switch-frame> G <switch-frame>
<switch-frame> <switch-frame> C-x C-w C-g <C-tab> C-x
C-w C-g C-x k <return> <C-tab> C-z d <backspace> c
d <return> w h i l e SPC # ' ( C-e <backspace> C-b
l a m b d a SPC ( C-f SPC t C-e SPC { SPC e c h o SPC
X X X C-e C-b ; SPC s l e e p SPC 1 C-e <return> <switch-frame>
C-p RET RET <switch-frame> <switch-frame> n n E ( c
u r r e n t - b u f f f e r C-b C-b <backspace> C-e
C-c C-u <C-tab> n n n n n n n n n n n n n n n <switch-frame>
C-x b s c r <return> ( w i t h - t e m p <M-tab> b
u <M-tab> <return> ( l e t SPC ( b u f SPC ( b <backspace>
c u r r e n t - b u f f e r ) ) ) ( s i t - f o r SPC
1 ) ( f o r m a t SPC C-h f <return> " : % s : SPC
: % s : C-f SPC ( b u f f e r - n a m e SPC b u f C-f
SPC ( c u r r e n t - b u f f e r C-e C-x C-e C-x 1
<switch-frame> <switch-frame> M-N M-< C-SPC C-e C-n
C-n C-n C-e C-w <switch-frame> <switch-frame> C-z M->
C-c C-c M-p C-a C-k <switch-frame> <switch-frame> <switch-frame>
<switch-frame> C-x 1 M-x r e p o r t - e m a c s -
b u g <return>
Recent messages:
Result: nil [4 times]
Result: #<process /home/dhansen/bin/w3m>
Result: exit
Result: nil [3 times]
Result: #<process /home/dhansen/bin/w3m>
Result: 0 (#o0, #x0, ?\C-@) [3 times]
Parsing BBDB... (frobnicating...done)
": *temp*: :*eshell*:"
Mark set [3 times]
History item: 128
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 23.0.50; `read-event' changes `current-buffer'
2007-11-03 5:30 23.0.50; `read-event' changes `current-buffer' David Hansen
@ 2007-11-03 17:14 ` Johan Bockgård
2007-11-07 3:47 ` Glenn Morris
0 siblings, 1 reply; 3+ messages in thread
From: Johan Bockgård @ 2007-11-03 17:14 UTC (permalink / raw)
To: emacs-devel; +Cc: emacs-pretest-bug
David Hansen <david.hansen@gmx.net> writes:
> $ emacs -Q
> M-x eshell RET
> $ while #'(lambda () t) { echo XXX; sleep 1}
> C-x b *scratch* RET
>
> (with-temp-buffer
> (let ((buf (current-buffer)))
> (read-event nil nil 3)
> (format ":%s: :%s:" (buffer-name buf) (current-buffer))))
>
> C-u C-x C-e
>
> ": *temp*: :*eshell*:"
It is caused by an unprotected set-buffer call in eshell-sentinel.
This patch fixes this. It also uses with-current-buffer in
eshell-insertion-filter, and in eshell-output-filter (instead of
(set-buffer BUF) ... (set-buffer OLDBUF)).
2007-11-03 Johan Bockgård <bojohan@gnu.org>
* eshell/esh-proc.el (eshell-insertion-filter, eshell-sentinel):
Use `with-current-buffer'.
* eshell/esh-mode.el (eshell-output-filter): Ditto.
Index: lisp/eshell/esh-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/eshell/esh-mode.el,v
retrieving revision 1.31
diff -u -r1.31 esh-mode.el
--- lisp/eshell/esh-mode.el 21 Oct 2007 07:33:32 -0000 1.31
+++ lisp/eshell/esh-mode.el 3 Nov 2007 16:58:32 -0000
@@ -775,38 +775,36 @@
(setq string (funcall (car functions) string))
(setq functions (cdr functions))))
(if (and string oprocbuf (buffer-name oprocbuf))
- (let ((obuf (current-buffer))
- opoint obeg oend)
- (set-buffer oprocbuf)
- (setq opoint (point))
- (setq obeg (point-min))
- (setq oend (point-max))
- (let ((buffer-read-only nil)
- (nchars (length string))
- (ostart nil))
- (widen)
- (goto-char eshell-last-output-end)
- (setq ostart (point))
- (if (<= (point) opoint)
- (setq opoint (+ opoint nchars)))
- (if (< (point) obeg)
- (setq obeg (+ obeg nchars)))
- (if (<= (point) oend)
- (setq oend (+ oend nchars)))
- (insert-before-markers string)
- (if (= (window-start (selected-window)) (point))
- (set-window-start (selected-window)
- (- (point) nchars)))
- (if (= (point) eshell-last-input-end)
- (set-marker eshell-last-input-end
- (- eshell-last-input-end nchars)))
- (set-marker eshell-last-output-start ostart)
- (set-marker eshell-last-output-end (point))
- (force-mode-line-update))
- (narrow-to-region obeg oend)
- (goto-char opoint)
- (eshell-run-output-filters)
- (set-buffer obuf)))))
+ (let (opoint obeg oend)
+ (with-current-buffer oprocbuf
+ (setq opoint (point))
+ (setq obeg (point-min))
+ (setq oend (point-max))
+ (let ((buffer-read-only nil)
+ (nchars (length string))
+ (ostart nil))
+ (widen)
+ (goto-char eshell-last-output-end)
+ (setq ostart (point))
+ (if (<= (point) opoint)
+ (setq opoint (+ opoint nchars)))
+ (if (< (point) obeg)
+ (setq obeg (+ obeg nchars)))
+ (if (<= (point) oend)
+ (setq oend (+ oend nchars)))
+ (insert-before-markers string)
+ (if (= (window-start (selected-window)) (point))
+ (set-window-start (selected-window)
+ (- (point) nchars)))
+ (if (= (point) eshell-last-input-end)
+ (set-marker eshell-last-input-end
+ (- eshell-last-input-end nchars)))
+ (set-marker eshell-last-output-start ostart)
+ (set-marker eshell-last-output-end (point))
+ (force-mode-line-update))
+ (narrow-to-region obeg oend)
+ (goto-char opoint)
+ (eshell-run-output-filters))))))
(defun eshell-run-output-filters ()
"Run the `eshell-output-filter-functions' on the current output."
Index: lisp/eshell/esh-proc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/eshell/esh-proc.el,v
retrieving revision 1.16
diff -u -r1.16 esh-proc.el
--- lisp/eshell/esh-proc.el 26 Jul 2007 05:26:54 -0000 1.16
+++ lisp/eshell/esh-proc.el 3 Nov 2007 16:58:33 -0000
@@ -335,39 +335,39 @@
PROC is the process for which we're inserting output. STRING is the
output."
(when (buffer-live-p (process-buffer proc))
- (set-buffer (process-buffer proc))
- (let ((entry (assq proc eshell-process-list)))
- (when entry
- (setcar (nthcdr 3 entry)
- (concat (nth 3 entry) string))
- (unless (nth 4 entry) ; already being handled?
- (while (nth 3 entry)
- (let ((data (nth 3 entry)))
- (setcar (nthcdr 3 entry) nil)
- (setcar (nthcdr 4 entry) t)
- (eshell-output-object data nil (cadr entry))
- (setcar (nthcdr 4 entry) nil))))))))
+ (with-current-buffer (process-buffer proc)
+ (let ((entry (assq proc eshell-process-list)))
+ (when entry
+ (setcar (nthcdr 3 entry)
+ (concat (nth 3 entry) string))
+ (unless (nth 4 entry) ; already being handled?
+ (while (nth 3 entry)
+ (let ((data (nth 3 entry)))
+ (setcar (nthcdr 3 entry) nil)
+ (setcar (nthcdr 4 entry) t)
+ (eshell-output-object data nil (cadr entry))
+ (setcar (nthcdr 4 entry) nil)))))))))
(defun eshell-sentinel (proc string)
"Generic sentinel for command processes. Reports only signals.
PROC is the process that's exiting. STRING is the exit message."
(when (buffer-live-p (process-buffer proc))
- (set-buffer (process-buffer proc))
- (unwind-protect
- (let* ((entry (assq proc eshell-process-list)))
-; (if (not entry)
-; (error "Sentinel called for unowned process `%s'"
-; (process-name proc))
- (when entry
- (unwind-protect
- (progn
- (unless (string= string "run")
- (unless (string-match "^\\(finished\\|exited\\)" string)
- (eshell-insertion-filter proc string))
- (eshell-close-handles (process-exit-status proc) 'nil
- (cadr entry))))
- (eshell-remove-process-entry entry))))
- (run-hook-with-args 'eshell-kill-hook proc string))))
+ (with-current-buffer (process-buffer proc)
+ (unwind-protect
+ (let* ((entry (assq proc eshell-process-list)))
+;;; (if (not entry)
+;;; (error "Sentinel called for unowned process `%s'"
+;;; (process-name proc))
+ (when entry
+ (unwind-protect
+ (progn
+ (unless (string= string "run")
+ (unless (string-match "^\\(finished\\|exited\\)" string)
+ (eshell-insertion-filter proc string))
+ (eshell-close-handles (process-exit-status proc) 'nil
+ (cadr entry))))
+ (eshell-remove-process-entry entry))))
+ (run-hook-with-args 'eshell-kill-hook proc string)))))
(defun eshell-process-interact (func &optional all query)
"Interact with a process, using PROMPT if more than one, via FUNC.
--
Johan Bockgård
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 23.0.50; `read-event' changes `current-buffer'
2007-11-03 17:14 ` Johan Bockgård
@ 2007-11-07 3:47 ` Glenn Morris
0 siblings, 0 replies; 3+ messages in thread
From: Glenn Morris @ 2007-11-07 3:47 UTC (permalink / raw)
To: emacs-devel
Johan Bockgård wrote:
> This patch fixes this.
Thanks; installed.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-11-07 3:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-03 5:30 23.0.50; `read-event' changes `current-buffer' David Hansen
2007-11-03 17:14 ` Johan Bockgård
2007-11-07 3:47 ` Glenn Morris
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.