GNU bug report logs - #48716
28.0.50; Spurious output from term-emulate-terminal when in line-mode

Previous Next

Package: emacs;

Reported by: Massimiliano Mirra <hyperstruct <at> gmail.com>

Date: Fri, 28 May 2021 15:13:01 UTC

Severity: normal

Found in version 28.0.50

To reply to this bug, email your comments to 48716 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#48716; Package emacs. (Fri, 28 May 2021 15:13:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Massimiliano Mirra <hyperstruct <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 28 May 2021 15:13:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Massimiliano Mirra <hyperstruct <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; Spurious output from term-emulate-terminal when in line-mode
Date: Fri, 28 May 2021 16:00:52 +0100
[Message part 1 (text/plain, inline)]
Spurious output is occasionally produced when running a command
with `make-term', and the command performs cursor movements and
partial screen clears.

- Reproduction #1 shows what happens when using `yarn' to install
  packages in a NodeJS project. (For ease and reliability of
  reproduction, a recording made with script(1) is run instead
  of the actual command.)

  Run with: emacs -Q -l repro-1.el
  Preview: https://asciinema.org/a/4mMv1aIrMmizwxr01AaEXMQqe

- Reproduction #2 shows a minimal (provided) Python program that
  creates a progress bar.

  Run with: emacs -Q -l repro-2.el
  Preview: https://asciinema.org/a/K6XCPbgkuqk6op4KQyiX9L5n7

The problem only happens in `term-line-mode' (the default).
`term-char-mode' works fine.  It is affected by the rate of output:
changing "scriptreplay" in repro-1.el to "scriptreplay -d 5" (5x
speed) still produces different, though still wrong, output.

The culprit appears to be following lines from `term-emulate-terminal'
in term.el; commenting them out fixes this problem:

   (when (and (> (point-max) (process-mark proc))
      (term-in-line-mode))
     (narrow-to-region (point-min) (process-mark proc)))


In GNU Emacs 28.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.29,
cairo version 1.17.4)
 of 2021-05-16 built on 956e3d7386ff
Repository revision: 78575c53fc8c78de1494822f9f6680e2a21308d6
Repository branch: pgtk-nativecomp
Windowing system distributor 'System Description: Arch Linux

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
 --with-sound=alsa --with-modules --with-x-toolkit=gtk3 --with-cairo
 --with-xwidgets --with-native-compilation --with-pgtk
 --without-compress-install --without-gconf --without-gsettings
 --without-m17n-flt --enable-autodepend --enable-link-time-optimization
 CC=/usr/bin/clang 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe
 -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2,-D_GLIBCXX_ASSERTIONS
 -Wformat -Werror=format-security -fstack-clash-protection
 -fcf-protection -g -flto'
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now
 'CPP=/usr/bin/clang -E''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM HARFBUZZ JPEG JSON LCMS2
LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER
PGTK PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS XIM
XWIDGETS GTK3 ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_MESSAGES: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-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

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/pgtk-win pgtk-win term/common-win tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads
xwidget-internal dbusbind inotify dynamic-setting font-render-setting
cairo move-toolbar gtk x-toolkit pgtk lcms2 multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 69245 8432)
 (symbols 48 6922 0)
 (strings 32 20554 2262)
 (string-bytes 1 684028)
 (vectors 16 13527)
 (vector-slots 8 293613 14217)
 (floats 8 22 39)
 (intervals 56 240 0)
 (buffers 992 10))

-- 
Massimiliano Mirra
massimilianomirra.com
[Message part 2 (text/html, inline)]
[repro-1.el (text/x-emacs-lisp, attachment)]
[repro-1.timingfile (application/octet-stream, attachment)]
[repro-1.script (application/octet-stream, attachment)]
[repro-2.el (text/x-emacs-lisp, attachment)]
[repro-2.py (text/x-python, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48716; Package emacs. (Fri, 03 Jun 2022 02:47:02 GMT) Full text and rfc822 format available.

Message #8 received at 48716 <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Massimiliano Mirra <hyperstruct <at> gmail.com>, 48716 <at> debbugs.gnu.org
Subject: Re: bug#48716: 28.0.50; Spurious output from term-emulate-terminal
 when in line-mode
Date: Thu, 02 Jun 2022 19:46:14 -0700
Hello,

On Fri 28 May 2021 at 04:00PM +01, Massimiliano Mirra wrote:

> Spurious output is occasionally produced when running a command
> with `make-term', and the command performs cursor movements and
> partial screen clears.
>
> [...]
>
> The culprit appears to be following lines from `term-emulate-terminal'
> in term.el; commenting them out fixes this problem:
>
>    (when (and (> (point-max) (process-mark proc))
>       (term-in-line-mode))
>      (narrow-to-region (point-min) (process-mark proc)))

The code assumes anything after the process mark is prospective input,
which is very often going to be wrong when the command moves the cursor
-- even if the command just emits \r.  One way to fix this might be to
add text properties to actual output, thereby distinguishing it from
something the user has typed.

-- 
Sean Whitton




This bug report was last modified 1 year and 336 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.