Subject: 25.2; visual-line-mode freezes Emacs, unresponsive to C-g
From: Michael Ernst <[email-masked]>
To: [email-masked]
Date: Mon, 07 May 2018 07:58:32 -0700 (PDT)
List-Id: <debbugs-submit.debbugs.gnu.org>

To reproduce the problem:
  * emacs -Q
  * visit the attached text (file long-visual-line-repro.el) in a buffer
  * M-x eval-buffer
  * C-n through the buffer until Emacs freezes, on the long "xxx...xxx" 
line

Emacs freezes, uses 100% of CPU, and is unresponsive to C-g keystrokes.

 From cursory experimentation, the problem seems to occur when both the
wrap-prefix, and a single word, are longer than the Emacs window is wide.

This bug freezes my Emacs frequently.

                     -Michael Ernst

In GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.21)
  of 2017-09-22, modified by Debian built on lgw01-amd64-050
Windowing system distributor 'The X.Org Foundation', version 11.0.11905000
System Description:	Ubuntu 17.10

Configured using:
  'configure --build x86_64-linux-gnu --prefix=/usr 
--sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib 
--infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes 
--enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.2/site-lisp:/usr/share/emacs/site-lisp 
--with-sound=alsa --without-gconf --build x86_64-linux-gnu --prefix=/usr 
--sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib 
--infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes 
--enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.2/site-lisp:/usr/share/emacs/site-lisp 
--with-sound=alsa --without-gconf --with-x=yes --with-x-toolkit=gtk3 
--with-toolkit-scroll-bars 'CFLAGS=-g -O2 
-fdebug-prefix-map=/build/emacs25-jYekUr/emacs25-25.2+1=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wall' 
'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 
'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY ACL 
LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB 
TOOLKIT_SCROLL_BARS GTK3 X11

Important settings:
   value of $LC_ALL: en_US.utf8
   value of $LANG: en_US.UTF-8
   value of $XMODIFIERS: @im=ibus
   locale-coding-system: utf-8-unix

Major mode: Text

Minor modes in effect:
   global-semanticdb-minor-mode: t
   global-semantic-idle-scheduler-mode: t
   semantic-mode: t
   magit-auto-revert-mode: t
   global-git-commit-mode: t
   async-bytecomp-package-mode: t
   diff-auto-refine-mode: t
   adaptive-wrap-prefix-mode: t
   dired-omit-mode: t
   global-edit-server-edit-mode: t
   type-break-mode: t
   dtrt-indent-mode: t
   ido-everywhere: t
   shell-dirtrack-mode: t
   tooltip-mode: t
   global-eldoc-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   visual-line-mode: t
   transient-mark-mode: t
   abbrev-mode: t

Recent messages:
Saving file /home/mernst/Mail/draft/1...
Wrote /home/mernst/Mail/draft/1
Reverting buffer ‘mew-mde.el’.
command-execute: Command attempted to use minibuffer while in minibuffer
Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %; q to quit; ? for help.
Mark set [3 times]
nil
Quit
Saving file /home/mernst/sync/long-visual-line-repro.el...
Wrote /home/mernst/sync/long-visual-line-repro.el

Load-path shadows:
/usr/share/emacs/25.2/site-lisp/debian-startup hides 
/usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs25/site-lisp/cmake-data/cmake-mode hides 
/usr/share/emacs/site-lisp/cmake-mode

Features:
(shadow emacsbug semantic/html sgml-mode tramp-cmds tramp-cache tramp-sh 
bdiff semantic/tag-write semantic/decorate/mode semantic/edit semantic/dep 
semantic/tag-file semantic/db-find semantic/db-ref semantic/db-mode 
semantic/wisent/java-tags semantic/wisent/javat-wy semantic/wisent 
semantic/wisent/wisent google-c-style jdee-plugins jdee derived jdee-wiz 
jdee-test jdee-archive memoize jdee-stacktrace jdee-refactor 
jdee-project-file jdee-maven jdee-keys jdee-jdb jdee-java-grammar 
jdee-which-method jdee-font-lock jdee-issues jdee-help jdee-gen tempo 
jdee-find jdee-deps jdee-cygwin jdee-custom jdee-compile jdee-class 
jdee-bytecode jdee-bug jdee-run jdee-jdk-manager jdee-dbs jdee-dbo 
jdee-widgets tree-widget jdee-db jdee-open-source semantic/senator 
semantic/decorate pulse jdee-import jdee-complete semantic/idle jdee-parse 
jdee-backend jdee-bsh jdee-util jdee-parse-expr beanshell rx jdee-imenu 
semantic/imenu semantic/sb semantic/sort semantic/db-file data-debug 
cedet-files semantic/db eieio-base semantic/java semantic/format 
semantic/tag-ls semantic/find semantic/doc semantic/ctxt 
semantic/util-modes semantic/util semantic semantic/tag semantic/lex 
semantic/fw mode-local efc eieio-compat avl-tree jdee-annotations 
jdee-abbrev jdee-classpath jdee-files jdee-activator jdee-log cus-edit 
cus-start cus-load wid-edit cedet compare-w bbdb-gui tabify imenu man 
url-http url-gw url-auth url-queue url-cache url url-proxy url-privacy 
url-expand url-methods url-history url-cookie url-domsuf mailcap shr-color 
color url-util shr dom subr-x bbdb-hooks mail-extr rmail-mde mail-simplify 
mailalias rmail bbdb-com qp network-stream nsm starttls tls gnutls 
bbdb-mew mew-varsx mew-unix mew-mde mew-auth mew-config mew-imap2 mew-imap 
mew-nntp2 mew-nntp mew-pop mew-smtp mew-ssl mew-ssh mew-net mew-highlight 
mew-sort mew-fib mew-ext mew-refile mew-demo mew-attach mew-draft 
mew-message mew-thread mew-virtual mew-summary4 mew-summary3 mew-summary2 
mew-summary mew-search mew-pick mew-passwd mew-scan mew-syntax mew-bq 
mew-smime mew-pgp mew-header mew-exec mew-mark mew-mime mew-edit 
mew-decode mew-encode mew-cache mew-minibuf mew-complete mew-addrbook 
mew-local mew-vars3 mew-vars2 mew-vars mew-env mew-mule3 mew-mule 
mew-gemacs mew-key mew-func mew-blvs mew-const mew pp magit-extras dabbrev 
vc vc-dispatcher jka-compr eieio-opt speedbar sb-image ezimage dframe 
find-func misearch multi-isearch magit-obsolete magit-blame magit-stash 
magit-bisect magit-remote magit-commit magit-sequence magit-notes 
magit-worktree magit-branch magit-files magit-refs magit-status magit 
magit-repos magit-apply magit-wip magit-log magit-diff smerge-mode 
magit-core magit-autorevert autorevert filenotify magit-process 
magit-margin magit-mode magit-git magit-section magit-popup git-commit 
magit-utils crm log-edit message rfc822 mml mml-sec epg mm-decode 
mm-bodies mm-encode mail-parse rfc2231 gmm-utils mailheader pcvs-util 
add-log with-editor async-bytecomp async dash vc-git pt grep diff-mode 
diff time-stamp adaptive-wrap dired-aux dired-mde arc-mode archive-mode 
dired-x dired dot-emacs bbdb-autoloads fill-column-indicator edit-server 
edmacro kmacro warnings server ff-paths ffap url-parse url-vars type-break 
ftp-mde sendmail-mde rmail-addresses-mde ispell mail-utils-mde 
startup-functions-mde etags-mde sendmail rfc2047 rfc2045 ietf-drums 
mail-utils prog-modes-mde honorary-compile inf-lisp perl-mode sh-script 
smie cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align 
cc-engine yaml-mode dtrt-indent mode-hooks-mde mouse-goto-error etags xref 
project bibtex util-mde inleft darken-lighten-face buffer-menu-mde 
mailabbrev bbdb-mde bbdb timezone edebug benchmark-init finder-inf info 
package epg-config ido seq ess-toolbar ess-mouse mouseme thingatpt 
browse-url ess-menu ess-swv ess-noweb ess-noweb-font-lock-mode ess-bugs-l 
essd-els ess-sas-d ess-sas-l ess-sas-a ess-sta-d ess-sta-l cc-vars cc-defs 
make-regexp ess-sp6-d ess-dde ess-sp3-d ess-julia ess-r-d ess-r-syntax 
ess-r-completion ess-roxy essddr noutline outline easy-mmode hideshow 
ess-help ess-r-package ess-s-l ess ess-inf ess-tracebug compile tramp 
tramp-compat auth-source cl-seq eieio byte-opt bytecomp byte-compile 
cl-extra cconv eieio-core gnus-util mm-util help-fns help-mode mail-prsvr 
password-cache tramp-loaddefs cl-macs trampver ucs-normalize shell 
pcomplete comint ansi-color ring format-spec advice ess-mode 
ess-noweb-mode ess-utils ess-generics cl gv cl-loaddefs pcase cl-lib 
ess-custom executable easymenu ess-compat ess-site time-date mule-util 
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel 
x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe 
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page 
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock 
syntax facemenu font-core frame 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 charscript case-table epa-hook jka-cmpr-hook help simple 
abbrev minibuffer cl-preloaded nadvice loaddefs button faces cus-face 
macroexp files text-properties overlay sha1 md5 base64 format env 
code-pages mule custom widget hashtable-print-readable backquote dbusbind 
inotify dynamic-setting system-font-setting font-render-setting 
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 1499516 923741)
  (symbols 48 103741 1)
  (miscs 40 23424 3276)
  (strings 32 368311 32240)
  (string-bytes 1 8130841)
  (vectors 16 132467)
  (vector-slots 8 2519468 56612)
  (floats 8 1661 1062)
  (intervals 56 37382 6051)
  (buffers 976 192))
;;; To reproduce the problem:
;;;  * emacs -Q
;;;  * visit this text in a buffer
;;;  * M-x eval-buffer
;;;  * C-n through the buffer until Emacs freezes, on the long "xxx...xxx" 
line

;;; short line
;;; long line long line long line long line long line long line long line 
long line long line long line
;;; short line
;;; 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;;; short line

(progn
   ;; (find-file "~/tmp/longline.txt-BAD-1")
   (visual-line-mode 1)
   ;; wrap-prefix for second line is 100 spaces
   (put-text-property 199 302 'wrap-prefix (make-string 100 32))
   ;; wrap-prefix for fourth line is 100 spaces
   (put-text-property 318 422 'wrap-prefix (make-string 100 32))
   )

;;; Emacs freezes, uses 100% of CPU, and is unresponsive to C-g keystrokes.

;;; From cursory experimentation, the problem seems to occur when both the
;;; wrap-prefix, and a single word, are longer than the Emacs window is 
wide.