GNU bug report logs - #45628
28.0.50; Scrolling on echo area with pixel-scroll-mode enabled locks up Emacs

Previous Next

Package: emacs;

Reported by: Amin Bandali <bandali <at> gnu.org>

Date: Sun, 3 Jan 2021 16:15:01 UTC

Severity: normal

Found in version 28.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 45628 in the body.
You can then email your comments to 45628 AT debbugs.gnu.org in the normal way.

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#45628; Package emacs. (Sun, 03 Jan 2021 16:15:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Amin Bandali <bandali <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 03 Jan 2021 16:15:01 GMT) Full text and rfc822 format available.

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

From: Amin Bandali <bandali <at> gnu.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; Scrolling on echo area with pixel-scroll-mode enabled
 locks up Emacs
Date: Sun, 03 Jan 2021 11:14:35 -0500
As the Subject says, scrolling using the mouse wheel on the echo area
causes Emacs to freeze/lock up (cursor is changed to spinning circle),
when pixel-scroll-mode is enabled.

I can reproduce in emacs -Q after evaluating the following in *scratch*:

(require 'pixel-scroll)
(pixel-scroll-mode 1)

In GNU Emacs 28.0.50 (build 17, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.10, Xaw3d scroll bars)
 of 2021-01-03 built on trisquel
Repository revision: 825b4ec338e82869dc656c7041ab2483b6c22479
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Trisquel GNU/Linux Etiona (9.0)

Configured using:
 'configure --without-gconf --without-gsettings --without-gpm
 --with-x-toolkit=lucid --with-xaw3d --with-mailutils'

Configured features:
XAW3D XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND DBUS GLIB NOTIFY INOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB
TOOLKIT_SCROLL_BARS LUCID X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON
PDUMPER LCMS2

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

Major mode: Lisp Interaction

Minor modes in effect:
  yas-global-mode: t
  yas-minor-mode: t
  global-hl-todo-mode: t
  hl-todo-mode: t
  global-page-break-lines-mode: t
  page-break-lines-mode: t
  recentf-mode: t
  display-battery-mode: t
  display-time-mode: t
  save-place-mode: t
  savehist-mode: t
  show-paren-mode: t
  icomplete-mode: t
  fido-mode: t
  server-mode: t
  winner-mode: t
  global-auto-revert-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  global-prettify-symbols-mode: t
  prettify-symbols-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
  temp-buffer-resize-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow orgalist org ob ob-tangle ob-ref ob-lob ob-table ob-exp
org-macro org-footnote org-src ob-comint org-pcomplete pcomplete comint
org-list org-faces org-entities noutline outline org-version
ob-emacs-lisp ob-core ob-eval org-table ol org-keys org-compat org-macs
org-loaddefs flyspell ispell emacsbug vc-git diff-mode sort smiley
ansi-color gnus-cite mail-extr gnus-async gnus-bcklg gnus-draft gnus-ml
gnus-topic nndraft nnmh gnutls utf-7 epa-file network-stream nsm
nnfolder nnnil gnus-agent gnus-srvr gnus-score score-mode nnvirtual nntp
gnus-cache ebdb-gnus gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime
smime dig gnus-sum shr kinsoku svg dom gnus-group gnus-undo gnus-start
gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo
parse-time iso8601 gnus-spec gnus-int gnus-range gnus-win ebdb-message
sendmail message rmc puny dired-x dired dired-loaddefs rfc822 mml
mml-sec epa derived epg epg-config mm-decode mm-bodies mm-encode
mail-parse rfc2231 gmm-utils mailheader ebdb-mua ebdb-com crm
ebdb-format ebdb mailabbrev eieio-opt speedbar ezimage dframe find-func
eieio-base cal-menu calendar cal-loaddefs timezone gnus nnheader
gnus-util rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums
text-property-search time-date mail-utils mm-util mail-prsvr boxquote
rect yasnippet hl-todo pcase disp-table page-break-lines easy-mmode
delight recentf tree-widget wid-edit format-spec battery dbus time xml
finder-inf info package browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util mailcap
url-handlers url-parse auth-source password-cache json subr-x map
url-vars cl-extra help-mode saveplace savehist paren bandali-erc
bandali-ebdb bandali-message bandali-gnus bandali-dired bandali-ibuffer
ibuf-macs bandali-eshell icomplete bandali-org bandali-exwm exwm-edit
exwm-systemtray xcb-systemtray xcb-xembed exwm-randr xcb-randr
exwm-config ido seq exwm exwm-input xcb-keysyms xcb-xkb exwm-manage
exwm-floating xcb-cursor xcb-render exwm-layout exwm-workspace exwm-core
easymenu xcb-ewmh xcb-icccm xcb xcb-xproto xcb-types cl-seq xcb-debug
eieio byte-opt bytecomp byte-compile cconv eieio-core eieio-loaddefs
server edmacro kmacro advice winner ring autorevert filenotify cl-macs
gv cl-loaddefs cl-lib iso-transl tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd 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 timer
select scroll-bar mouse jit-lock font-lock syntax facemenu 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 dbusbind inotify lcms2
dynamic-setting font-render-setting cairo x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 332287 11838)
 (symbols 48 35073 4)
 (strings 32 103624 4194)
 (string-bytes 1 3551705)
 (vectors 16 68136)
 (vector-slots 8 1025323 12351)
 (floats 8 392 338)
 (intervals 56 825 0)
 (buffers 984 11))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45628; Package emacs. (Sun, 03 Jan 2021 17:31:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Amin Bandali <bandali <at> gnu.org>, Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 45628 <at> debbugs.gnu.org
Subject: Re: bug#45628: 28.0.50;
 Scrolling on echo area with pixel-scroll-mode enabled locks up Emacs
Date: Sun, 03 Jan 2021 19:30:33 +0200
> From: Amin Bandali <bandali <at> gnu.org>
> Date: Sun, 03 Jan 2021 11:14:35 -0500
> 
> As the Subject says, scrolling using the mouse wheel on the echo area
> causes Emacs to freeze/lock up (cursor is changed to spinning circle),
> when pixel-scroll-mode is enabled.
> 
> I can reproduce in emacs -Q after evaluating the following in *scratch*:
> 
> (require 'pixel-scroll)
> (pixel-scroll-mode 1)

Thanks.

Tak, can you please look into this?  The code infloops inside
pixel-scroll-down, here:

        (while (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
          (vertical-motion -1))              ; move point upward

because the mini-window is normally just one screen line high, so its
top and bottom coincide.

Shouldn't we exit the loop when vertical-motion returns zero, which
means it didn't move?

A similar loop exists in pixel-scroll-up, AFAICS.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45628; Package emacs. (Mon, 04 Jan 2021 08:59:01 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: 45628 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Amin Bandali <bandali <at> gnu.org>
Cc: 国広卓也 <tkk <at> misasa.okayama-u.ac.jp>
Subject: Re: bug#45628: 28.0.50; Scrolling on echo area with pixel-scroll-mode
 enabled locks up Emacs
Date: Mon, 4 Jan 2021 17:57:48 +0900
>> As the Subject says, scrolling using the mouse wheel on the echo area
>> causes Emacs to freeze/lock up (cursor is changed to spinning circle),
>> when pixel-scroll-mode is enabled.
> 
> Tak, can you please look into this?  The code infloops inside
> pixel-scroll-down, here:
> 
>        (while (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
>          (vertical-motion -1))              ; move point upward
> 
> because the mini-window is normally just one screen line high, so its
> top and bottom coincide.
> 
> Shouldn't we exit the loop when vertical-motion returns zero, which
> means it didn't move?
> 
> A similar loop exists in pixel-scroll-up, AFAICS.

Thank you to shoot the problem. 
I confirmed the problem and Eli's suggestion solves it.

I think that following patch would work but usage of `while’
does not look cool.  If there can is better style, please
suggest me.



diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el
index cc0e159fae..c266c54a06 100644
--- a/lisp/pixel-scroll.el
+++ b/lisp/pixel-scroll.el
@@ -132,8 +132,8 @@ pixel-scroll-up
                    (pixel-line-height))))
         (if (pixel-eob-at-top-p)      ; when end-of-the-buffer is close
             (scroll-up 1)             ; relay on robust method
-          (while (pixel-point-at-top-p amt) ; prevent too late (multi tries)
-            (vertical-motion 1))            ; move point downward
+          (while (and (pixel-point-at-top-p amt) ; prevent too late (multi tries)
+                      (equal (vertical-motion 1) 1))) ; move point downward
           (pixel-scroll-pixel-up amt))))))  ; move scope downward
 
 (defun pixel-scroll-down (&optional arg)
@@ -149,8 +149,8 @@ pixel-scroll-down
                          pixel-resolution-fine-flag
                        (frame-char-height))
                    (pixel-line-height -1))))
-        (while (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
-          (vertical-motion -1))              ; move point upward
+        (while (and (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
+                    (equal (vertical-motion -1) -1))) ; move point upward
         (if (or (pixel-bob-at-top-p amt) ; when beginning-of-the-buffer is seen
                 (pixel-eob-at-top-p))    ; for file with a long line
             (scroll-down 1)              ; relay on robust method




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45628; Package emacs. (Mon, 04 Jan 2021 15:17:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 45628 <at> debbugs.gnu.org, bandali <at> gnu.org
Subject: Re: bug#45628: 28.0.50; Scrolling on echo area with pixel-scroll-mode
 enabled locks up Emacs
Date: Mon, 04 Jan 2021 17:16:35 +0200
> From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
> Date: Mon, 4 Jan 2021 17:57:48 +0900
> Cc: 国広卓也 <tkk <at> misasa.okayama-u.ac.jp>
> 
> I think that following patch would work but usage of `while’
> does not look cool.  If there can is better style, please
> suggest me.

How about a normal while loop with catch before it and throw inside?

> -          (while (pixel-point-at-top-p amt) ; prevent too late (multi tries)
> -            (vertical-motion 1))            ; move point downward
> +          (while (and (pixel-point-at-top-p amt) ; prevent too late (multi tries)
> +                      (equal (vertical-motion 1) 1))) ; move point downward
>            (pixel-scroll-pixel-up amt))))))  ; move scope downward
>  
>  (defun pixel-scroll-down (&optional arg)
> @@ -149,8 +149,8 @@ pixel-scroll-down
>                           pixel-resolution-fine-flag
>                         (frame-char-height))
>                     (pixel-line-height -1))))
> -        (while (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
> -          (vertical-motion -1))              ; move point upward
> +        (while (and (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
> +                    (equal (vertical-motion -1) -1))) ; move point upward

I think equality to 1 or -1 is too stringent.  vertical-motion could
move more if you have overlay strings or display strings at point that
include embedded newlines.  So I think you should test >= 1 and <= -1
respectively.

Also, I believe this problem exists on the emacs-27 branch as well,
right?  Then we should install there first.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45628; Package emacs. (Wed, 06 Jan 2021 00:48:02 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 45628 <at> debbugs.gnu.org,
 国広卓也 <tkk <at> misasa.okayama-u.ac.jp>,
 Amin Bandali <bandali <at> gnu.org>
Subject: Re: bug#45628: 28.0.50; Scrolling on echo area with pixel-scroll-mode
 enabled locks up Emacs
Date: Wed, 6 Jan 2021 09:47:26 +0900
> How about a normal while loop with catch before it and throw inside?
> 
> +          (while (and (pixel-point-at-top-p amt) ; prevent too late (multi tries)
> +                      (equal (vertical-motion 1) 1))) ; move point downward
> 
> +        (while (and (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
> +                    (equal (vertical-motion -1) -1))) ; move point upward
> 
> I think equality to 1 or -1 is too stringent.  vertical-motion could
> move more if you have overlay strings or display strings at point that
> include embedded newlines.  So I think you should test >= 1 and <= -1
> respectively.

I revised the patch and is attached on this message.


> Also, I believe this problem exists on the emacs-27 branch as well,
> right?  Then we should install there first.

Yes.  Can you install the patch with the commit message to emacs-27 branch?

TIA


commit message

    Avoid infloop on scrolling a window with one screen line height.
    
    * lisp/pixel-scroll.el (pixel-scroll-up, pixel-scroll-down): Escape
    while loop when point did not move by `vertical-motion'.  (Bug#45628)


diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el
index cc0e159fae..68dc0fb94b 100644
--- a/lisp/pixel-scroll.el
+++ b/lisp/pixel-scroll.el
@@ -132,8 +132,10 @@ pixel-scroll-up
                    (pixel-line-height))))
         (if (pixel-eob-at-top-p)      ; when end-of-the-buffer is close
             (scroll-up 1)             ; relay on robust method
-          (while (pixel-point-at-top-p amt) ; prevent too late (multi tries)
-            (vertical-motion 1))            ; move point downward
+          (catch 'no-movement
+            (while (pixel-point-at-top-p amt) ; prevent too late (multi tries)
+              (unless (>= (vertical-motion 1) 1) ; move point downward
+                (throw 'no-movement nil)))) ; exit loop when point did not move
           (pixel-scroll-pixel-up amt))))))  ; move scope downward
 
 (defun pixel-scroll-down (&optional arg)
@@ -149,8 +151,10 @@ pixel-scroll-down
                          pixel-resolution-fine-flag
                        (frame-char-height))
                    (pixel-line-height -1))))
-        (while (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
-          (vertical-motion -1))              ; move point upward
+        (catch 'no-movement
+          (while (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
+            (unless (<= (vertical-motion -1) -1) ; move point upward
+              (throw 'no-movement nil)))) ; exit loop when point did not move
         (if (or (pixel-bob-at-top-p amt) ; when beginning-of-the-buffer is seen
                 (pixel-eob-at-top-p))    ; for file with a long line
             (scroll-down 1)              ; relay on robust method






Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 09 Jan 2021 09:23:01 GMT) Full text and rfc822 format available.

Notification sent to Amin Bandali <bandali <at> gnu.org>:
bug acknowledged by developer. (Sat, 09 Jan 2021 09:23:01 GMT) Full text and rfc822 format available.

Message #22 received at 45628-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 45628-done <at> debbugs.gnu.org, bandali <at> gnu.org
Subject: Re: bug#45628: 28.0.50; Scrolling on echo area with pixel-scroll-mode
 enabled locks up Emacs
Date: Sat, 09 Jan 2021 11:22:35 +0200
> From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
> Date: Wed, 6 Jan 2021 09:47:26 +0900
> Cc: 国広卓也 <tkk <at> misasa.okayama-u.ac.jp>,
>  Amin Bandali <bandali <at> gnu.org>,
>  45628 <at> debbugs.gnu.org
> 
> > How about a normal while loop with catch before it and throw inside?
> > 
> > +          (while (and (pixel-point-at-top-p amt) ; prevent too late (multi tries)
> > +                      (equal (vertical-motion 1) 1))) ; move point downward
> > 
> > +        (while (and (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
> > +                    (equal (vertical-motion -1) -1))) ; move point upward
> > 
> > I think equality to 1 or -1 is too stringent.  vertical-motion could
> > move more if you have overlay strings or display strings at point that
> > include embedded newlines.  So I think you should test >= 1 and <= -1
> > respectively.
> 
> I revised the patch and is attached on this message.
> 
> 
> > Also, I believe this problem exists on the emacs-27 branch as well,
> > right?  Then we should install there first.
> 
> Yes.  Can you install the patch with the commit message to emacs-27 branch?

Thanks, I installed this on the emacs-27 branch, and I'm closing this
bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 06 Feb 2021 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 52 days ago.

Previous Next


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