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

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

bug#16576: Binding `standard-output' to a function doesn't work -- funct


From: Anders Lindgren
Subject: bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage
Date: Tue, 28 Jan 2014 10:09:08 +0100

Hi!

When binding `standard-output' to a function, is seems as though the function sometimes is called with garbage, like random control characters or part of the string in "random" order.

I've seen this problem in Emacs 22 and Emacs 24.3. I haven't been able to reproduce it on the Emacs trunk, but I've seen some problems (although less frequent) that could be explained if the problem existed there as well.

Steps to repeat:

    emacs -Q
    Eval the following:

(defvar bug-bind-output-str nil)

(defun bug-bind-output-function (char)
  (setq bug-bind-output-str
        (concat bug-bind-output-str (list char))))

(defun bug-bind-output-test ()
  (interactive)
  (let ((bug-bind-output-str "")
        (standard-output 'bug-bind-output-function)
        (s "(\\(co\\(?:mbine-after-change-calls\\|nd\\(?:ition-case\\(?:-unless-debug\\)?\\)?\\)\\|eval-\\(?:a\\(?:fter-load\\|nd-compile\\)\\|next-after-load\\|when\\(?:-compile\\)?\\)\\|i\\(?:f\\|nline\\)\\|l\\(?:ambda\\|et\\(?:\\*\\|rec\\)?\\)\\|p\\(?:case\\(?:-let\\*?\\)?\\|rog[*12nv]?\\)\\|save-\\(?:current-buffer\\|excursion\\|match-data\\|restriction\\|selected-window\\|window-excursion\\)\\|track-mouse\\|unwind-protect\\|w\\(?:hile\\(?:-no-input\\)?\\|ith-\\(?:c\\(?:a\\(?:\\(?:se\\|tegory\\)-table\\)\\|urrent-buffer\\)\\|demoted-errors\\|electric-help\\|local-quit\\|no-warnings\\|output-to-\\(?:string\\|temp-buffer\\)\\|s\\(?:elected-\\(?:frame\\|window\\)\\|ilent-modifications\\|yntax-table\\)\\|t\\(?:emp-\\(?:buffer\\|\\(?:fil\\|messag\\)e\\)\\|imeout\\(?:-handler\\)?\\)\\|wrapper-hook\\)\\)\\)\\>")
        s0)
    (prin1 s)
    bug-bind-output-str))

Type this a number of times:

    M-x (bug-bind-output-test) RET

A correct output looks like:


"\"(\\\\(co\\\\(?:mbine-after-change-calls\\\\|nd\\\\(?:ition-case\\\\(?:-unless-debug\\\\)?\\\\)?\\\\)\\\\|eval-\\\\(?:a\\\\(?:fter-load\\\\|nd-compile\\\\)\\\\|next-after-load\\\\|when\\\\(?:-compile\\\\)?\\\\)\\\\|i\\\\(?:f\\\\|nline\\\\)\\\\|l\\\\(?:ambda\\\\|et\\\\(?:\\\\*\\\\|rec\\\\)?\\\\)\\\\|p\\\\(?:case\\\\(?:-let\\\\*?\\\\)?\\\\|rog[*12nv]?\\\\)\\\\|save-\\\\(?:current-buffer\\\\|excursion\\\\|match-data\\\\|restriction\\\\|selected-window\\\\|window-excursion\\\\)\\\\|track-mouse\\\\|unwind-protect\\\\|w\\\\(?:hile\\\\(?:-no-input\\\\)?\\\\|ith-\\\\(?:c\\\\(?:a\\\\(?:\\\\(?:se\\\\|tegory\\\\)-table\\\\)\\\\|urrent-buffer\\\\)\\\\|demoted-errors\\\\|electric-help\\\\|local-quit\\\\|no-warnings\\\\|output-to-\\\\(?:string\\\\|temp-buffer\\\\)\\\\|s\\\\(?:elected-\\\\(?:frame\\\\|window\\\\)\\\\|ilent-modifications\\\\|yntax-table\\\\)\\\\|t\\\\(?:emp-\\\\(?:buffer\\\\|\\\\(?:fil\\\\|messag\\\\)e\\\\)\\\\|imeout\\\\(?:-handler\\\\)?\\\\)\\\\|wrapper-hook\\\\)\\\\)\\\\)\\\\>\""

This is an example of bad output, here, the last couple of lines does not correspond to the string being printed.

"\"(\\\\(co\\\\(?:mbine-after-change-calls\\\\|nd\\\\(?:ition-case\\\\(?:-unless-debug\\\\)?\\\\)?\\\\)\\\\|eval-\\\\(?:a\\\\(?:fter-load\\\\|nd-compile\\\\)\\\\|next-after-load\\\\|when\\\\(?:-compile\\\\)?\\\\)\\\\|i\\\\(?:f\\\\|nline\\\\)\\\\|l\\\\(?:ambda\\\\|et\\\\(?:\\\\*\\\\|rec\\\\)?\\\\)\\\\|p\\\\(?:case\\\\(?:-let\\\\*?\\\\)?\\\\|rog[*12nv]?\\\\)\\\\|save-\\\\(?:current-buffer\\\\|excursion\\\\|match-data\\\\|restriction\\\\|selected-window\\\\|window-excursion\\\\)\\\\|track-mouse\\\\|unwind-protect\\\\|w\\\\(?:hile\\\\(?:-no-input\\\\)?\\\\|ith-\\\\(?:c\\\\(?:a\\\\(?:\\\\(?:se\\\\|tegory\\\\\\\\(?:-no-input\\\\\\\\)?\\\\\\\\|ith-\\\\\\\\(?:c\\\\\\\\(?:a\\\\\\\\(?:\\\\\\\\(?:se\\\\\\\\|tegory\\\\locaw\\\"(\\\\\\\\(co\\\\\\\\(?:mbine-after-change-calls\\\\\\\\|nd\\\\\\\\(?:ition-case\\\\\\\\(?:-unless-debug\\\\\\\\)?\\\\\\\\)?\\\\\\\\)\\\\\\\\|eval-\\\\\\\\(?:a\\\\\\\\(?:fter-load\\\\\\\\|nd-compile\\\\\\\\)\\\\\\\\|next-after-load\\\\\\\\|when\\\\\\\\(?:-compile\\\\\\\\)?\\\\\\\\)\\\\\\\\|i\\\\\\\\(?:f\\\\\\\\|nline\\\\\\\\)\\\\\\\\|l\\\\\\\\(?:ambd\""

Other examples of bad output is if the string contains random control characters.

I've noticed that this is intermittent. Sometimes, say, every tenth call returns a broken string. Sometimes it feels as though you can call the function any number of times without getting a bad string.

Sincerely,
    Anders Lindgren


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'.
For information about debugging Emacs, please read the file
/Applications/Emacs24.3.app/Contents/Resources/etc/DEBUG.


In GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)
 of 2013-03-13 on bob.porkrind.org
Windowing system distributor `Apple', version 10.3.1265
Configured using:
 `configure '--host=x86_64-apple-darwin' '--build=i686-apple-darwin'
 '--with-ns' 'build_alias=i686-apple-darwin'
 'host_alias=x86_64-apple-darwin' 'CC=gcc -mmacosx-version-min=10.7
 -isystem
 /Users/david/Xcode-10.7_4.5.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/
 -F/Users/david/Xcode-10.7_4.5.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks''

Important settings:
  value of $LC_CTYPE: UTF-8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

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

Recent input:
<down> <right> <right> <escape> C-x <down> <down> <down> 
<escape> C-x <down> <down> <down> <down> <down> <down> 
<escape> C-x <escape> : ( b i g <backspace> <backspace> 
u g - b i <tab> t <tab> ) <return> <escape> : <up> 
<return> <escape> : <up> <return> <escape> : <up> <return> 
<escape> : <up> <return> <escape> : <up> <return> <escape> 
: <up> <return> <escape> : <up> <return> <escape> : 
<up> <return> <escape> : <up> <return> <escape> : <up> 
<return> <escape> : <up> <return> <escape> x e m a 
c s - b u <tab> C-g <escape> x m <backspace> e m a 
c s - b i <backspace> u g <tab> <s-backspace> <s-backspace> 
<escape> <backspace> <escape> <backspace> <escape> 
C-g r e p o r t - e m <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Loading vc-svn...done
bug-bind-output-str
bug-bind-output-function
bug-bind-output-test
"\"(\\\\(co\\\\(?:mbine-after-change-calls\\\\|nd\\\\(?:ition-case\\\\(?:-unless-debug\\\\)?\\\\)?\\\\)\\\\|eval-\\\\(?:a\\\\(?:fter-load\\\\|nd-compile\\\\)\\\\|next-after-load\\\\|when\\\\(?:-compile\\\\)?\\\\)\\\\|i\\\\(?:f\\\\|nline\\\\)\\\\|l\\\\(?:ambda\\\\|et\\\\(?:\\\\*\\\\|rec\\\\)?\\\\)\\\\|p\\\\(?:case\\\\(?:-let\\\\*?\\\\)?\\\\|rog[*12nv]?\\\\)\\\\|save-\\\\(?:current-buffer\\\\|excursion\\\\|match-data\\\\|restriction\\\\|selected-window\\\\|window-excursion\\\\)\\\\|track-mouse\\\\|unwind-protect\\\\|w\\\\(?:hile\\\\(?:-no-input\\\\)?\\\\|ith-\\\\(?:c\\\\(?:a\\\\(?:\\\\(?:se\\\\|tegory\\\\)-table\\\\)\\\\|urrent-buffer\\\\)\\\\|demoted-errors\\\\|electric-help\\\\|local-quit\\\\|no-warnings\\\\|output-to-\\\\(?:string\\\\|temp-buffer\\\\)\\\\|s\\\\(?:elected-\\\\(?:frame\\\\|window\\\\)\\\\|ilent-modifications\\\\|yntax-table\\\\)\\\\|t\\\\(?:emp-\\\\(?:buffer\\\\|\\\\(?:fil\\\\|messag\\\\)e\\\\)\\\\|imeout\\\\(?:-handler\\\\)?\\\\)\\\\|wrapper-hook\\\\)\\\\)\\\\)\\\\>\"" [11 times]
"\"(\\\\(co\\\\(?:mbine-after-change-calls\\\\|nd\\\\(?:ition-case\\\\(?:-unless-debug\\\\)?\\\\)?\\\\)\\\\|eval-\\\\(?:a\\\\(?:fter-load\\\\|nd-compile\\\\)\\\\|next-after-load\\\\|when\\\\(?:-compile\\\\)?\\\\)\\\\|i\\\\(?:f\\\\|nline\\\\)\\\\|l\\\\(?:ambda\\\\|et\\\\(?:\\\\*\\\\|rec\\\\)?\\\\)\\\\|p\\\\(?:case\\\\(?:-let\\\\*?\\\\)?\\\\|rog[*12nv]?\\\\)\\\\|save-\\\\(?:current-buffer\\\\|excursion\\\\|match-data\\\\|restriction\\\\|selected-window\\\\|window-excursion\\\\)\\\\|track-mouse\\\\|unwind-protect\\\\|w\\\\(?:hile\\\\(?:-no-input\\\\)?\\\\|ith-\\\\(?:c\\\\(?:a\\\\(?:\\\\(?:se\\\\|tegory\\\\\\\\(?:-no-input\\\\\\\\)?\\\\\\\\|ith-\\\\\\\\(?:c\\\\\\\\(?:a\\\\\\\\(?:\\\\\\\\(?:se\\\\\\\\|tegory\\\\locaw\\\"(\\\\\\\\(co\\\\\\\\(?:mbine-after-change-calls\\\\\\\\|nd\\\\\\\\(?:ition-case\\\\\\\\(?:-unless-debug\\\\\\\\)?\\\\\\\\)?\\\\\\\\)\\\\\\\\|eval-\\\\\\\\(?:a\\\\\\\\(?:fter-load\\\\\\\\|nd-compile\\\\\\\\)\\\\\\\\|next-after-load\\\\\\\\|when\\\\\\\\(?:-compile\\\\\\\\)?\\\\\\\\)\\\\\\\\|i\\\\\\\\(?:f\\\\\\\\|nline\\\\\\\\)\\\\\\\\|l\\\\\\\\(?:ambd\""
Quit

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils vc-dispatcher vc-svn time-date tooltip
ediff-hook vc-hooks lisp-float-type mwheel ns-win tool-bar dnd fontset
image regexp-opt fringe tabulated-list newcomment lisp-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process ns multi-tty emacs)


reply via email to

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