GNU bug report logs - #48812
28.0.50; describe-bindings stucks and gets high CPU load

Previous Next

Package: emacs;

Reported by: Naofumi Yasufuku <naofumi <at> yasufuku.dev>

Date: Thu, 3 Jun 2021 15:08:02 UTC

Severity: normal

Tags: confirmed, fixed, patch

Merged with 45379, 47494, 47565

Found in version 28.0.50

Fixed in version 28.1

Done: Stefan Kangas <stefan <at> marxist.se>

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 48812 in the body.
You can then email your comments to 48812 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#48812; Package emacs. (Thu, 03 Jun 2021 15:08:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Naofumi Yasufuku <naofumi <at> yasufuku.dev>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 03 Jun 2021 15:08:02 GMT) Full text and rfc822 format available.

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

From: Naofumi Yasufuku <naofumi <at> yasufuku.dev>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; describe-bindings stucks and gets high CPU load
Date: Fri, 4 Jun 2021 00:06:55 +0900
[Message part 1 (text/plain, inline)]
This describe-bindings stuck is caused by millions of shadow_lookup() calls
in src/keymap.c describe_vector().

------------------------------------------------------------------------
$ ./src/emacs
describe_vector] shadow_lookup loop START: definition=self-insert-command shadowed_by=nil starting_i=128 i=4194175
describe_vector] shadow_lookup loop END:   definition=self-insert-command shadowed_by=nil starting_i=128 i=4194175
describe_vector] shadow_lookup loop START: definition=self-insert-command shadowed_by=nil starting_i=4194176 i=4194303
describe_vector] shadow_lookup loop END:   definition=self-insert-command shadowed_by=nil starting_i=4194176 i=4194303
describe_vector] shadow_lookup loop START: definition=digit-argument shadowed_by=nil starting_i=48 i=57
describe_vector] shadow_lookup loop END:   definition=digit-argument shadowed_by=nil starting_i=48 i=57
$ 
------------------------------------------------------------------------
diff --git a/src/keymap.c b/src/keymap.c
index fb8eceaec1..0efa78ce9b 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -3065,6 +3065,11 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
       if (CHAR_TABLE_P (vector) && i != starting_i)
 	{
 	  Lisp_Object key = make_nil_vector (1);
+	  fprintf (stderr, "%s] shadow_lookup loop START: definition=%s shadowed_by=%s starting_i=%d i=%d\n",
+		   __func__,
+		   SDATA (SYMBOL_NAME (definition)),
+		   SDATA (SYMBOL_NAME (shadowed_by)),
+		   starting_i, i);
 	  for (int j = starting_i + 1; j <= i; j++)
 	    {
 	      ASET (key, 0, make_fixnum (j));
@@ -3072,6 +3077,11 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
 	      if (NILP (Fequal (tem, shadowed_by)))
 		i = j - 1;
 	    }
+	  fprintf (stderr, "%s] shadow_lookup loop END:   definition=%s shadowed_by=%s starting_i=%d i=%d\n",
+		   __func__,
+		   SDATA (SYMBOL_NAME (definition)),
+		   SDATA (SYMBOL_NAME (shadowed_by)),
+		   starting_i, i);
 	}
 
       /* If we have a range of more than one character,
------------------------------------------------------------------------


This shadow_lookup() loop was introduced by the following commit:

------------------------------------------------------------------------
commit a6490343366f2b2331a91dcb693effb3a9dd78f5
Author: Stefan Kangas <stefan <at> marxist.se>
Date:   Fri Nov 13 15:28:29 2020 +0100

    Don't show key ranges if shadowed by different commands

    * src/keymap.c (describe_vector): Make sure found consecutive keys
    are either not shadowed or, if they are, that they are shadowed by
    the same command.  (Bug#9293)
    * test/src/keymap-tests.el
    (help--describe-vector/bug-9293-one-shadowed-in-range): New test.

------------------------------------------------------------------------









In GNU Emacs 28.0.50 (build 3, aarch64-unknown-linux-gnu, GTK+ Version 3.24.25, cairo version 1.16.0)
 of 2021-06-03 built on phoebe
Repository revision: 089e0c4c55dcf72f9cf2f6f04b8a52fc7355499c
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101001
System Description: Ubuntu 21.04

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM
GTK3 ZLIB

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

Major mode: C/*l

Minor modes in effect:
  bug-reference-prog-mode: t
  tooltip-mode: t
  global-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
  abbrev-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny 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 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-git diff-mode easy-mmode vc
vc-dispatcher bug-reference cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs misearch multi-isearch
dired-aux dired dired-loaddefs time-date subr-x cl-extra seq byte-opt gv
bytecomp byte-compile cconv kmacro two-column help-mode 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 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 dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 118009 7881)
 (symbols 48 9308 1)
 (strings 32 27924 2053)
 (string-bytes 1 1038142)
 (vectors 16 18491)
 (vector-slots 8 227657 9510)
 (floats 8 31 163)
 (intervals 56 10630 0)
 (buffers 992 14))


[Message part 2 (text/html, inline)]
[28.0.50-describe-bindings-01.png (image/png, inline)]
[28.0.50-describe-bindings-02.png (image/png, inline)]
[27.1-ubuntu-describe-bindings.png (image/png, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48812; Package emacs. (Thu, 03 Jun 2021 15:16:02 GMT) Full text and rfc822 format available.

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

From: Naofumi Yasufuku <naofumi <at> yasufuku.dev>
To: 48812 <at> debbugs.gnu.org
Subject: Re: bug#48812: 28.0.50; describe-bindings stucks and gets high CPU
 load
Date: Fri, 4 Jun 2021 00:15:06 +0900
[Message part 1 (text/plain, inline)]
Attached simple patch could fix this.
Is there no regression with this change?

Regards,
—Naofumi

[0001-Fix-describe-bindings-stuck-caused-by-heavy-shadow_l.patch (application/octet-stream, attachment)]
[Message part 3 (text/plain, inline)]

> On Jun 4, 2021, at 0:06, Naofumi Yasufuku <naofumi <at> yasufuku.dev> wrote:
> 
> This describe-bindings stuck is caused by millions of shadow_lookup() calls
> in src/keymap.c describe_vector().
> 
> ------------------------------------------------------------------------
> $ ./src/emacs
> describe_vector] shadow_lookup loop START: definition=self-insert-command shadowed_by=nil starting_i=128 i=4194175
> describe_vector] shadow_lookup loop END:   definition=self-insert-command shadowed_by=nil starting_i=128 i=4194175
> describe_vector] shadow_lookup loop START: definition=self-insert-command shadowed_by=nil starting_i=4194176 i=4194303
> describe_vector] shadow_lookup loop END:   definition=self-insert-command shadowed_by=nil starting_i=4194176 i=4194303
> describe_vector] shadow_lookup loop START: definition=digit-argument shadowed_by=nil starting_i=48 i=57
> describe_vector] shadow_lookup loop END:   definition=digit-argument shadowed_by=nil starting_i=48 i=57
> $ 
> ------------------------------------------------------------------------
> diff --git a/src/keymap.c b/src/keymap.c
> index fb8eceaec1..0efa78ce9b 100644
> --- a/src/keymap.c
> +++ b/src/keymap.c
> @@ -3065,6 +3065,11 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
>        if (CHAR_TABLE_P (vector) && i != starting_i)
>  	{
>  	  Lisp_Object key = make_nil_vector (1);
> +	  fprintf (stderr, "%s] shadow_lookup loop START: definition=%s shadowed_by=%s starting_i=%d i=%d\n",
> +		   __func__,
> +		   SDATA (SYMBOL_NAME (definition)),
> +		   SDATA (SYMBOL_NAME (shadowed_by)),
> +		   starting_i, i);
>  	  for (int j = starting_i + 1; j <= i; j++)
>  	    {
>  	      ASET (key, 0, make_fixnum (j));
> @@ -3072,6 +3077,11 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
>  	      if (NILP (Fequal (tem, shadowed_by)))
>  		i = j - 1;
>  	    }
> +	  fprintf (stderr, "%s] shadow_lookup loop END:   definition=%s shadowed_by=%s starting_i=%d i=%d\n",
> +		   __func__,
> +		   SDATA (SYMBOL_NAME (definition)),
> +		   SDATA (SYMBOL_NAME (shadowed_by)),
> +		   starting_i, i);
>  	}
>  
>        /* If we have a range of more than one character,
> ------------------------------------------------------------------------
> 
> 
> This shadow_lookup() loop was introduced by the following commit:
> 
> ------------------------------------------------------------------------
> commit a6490343366f2b2331a91dcb693effb3a9dd78f5
> Author: Stefan Kangas <stefan <at> marxist.se>
> Date:   Fri Nov 13 15:28:29 2020 +0100
> 
>     Don't show key ranges if shadowed by different commands
> 
>     * src/keymap.c (describe_vector): Make sure found consecutive keys
>     are either not shadowed or, if they are, that they are shadowed by
>     the same command.  (Bug#9293)
>     * test/src/keymap-tests.el
>     (help--describe-vector/bug-9293-one-shadowed-in-range): New test.
> 
> ------------------------------------------------------------------------
> 
> 
> <28.0.50-describe-bindings-01.png>
> 
> <28.0.50-describe-bindings-02.png>
> 
> <27.1-ubuntu-describe-bindings.png>
> 
> 
> In GNU Emacs 28.0.50 (build 3, aarch64-unknown-linux-gnu, GTK+ Version 3.24.25, cairo version 1.16.0)
>  of 2021-06-03 built on phoebe
> Repository revision: 089e0c4c55dcf72f9cf2f6f04b8a52fc7355499c
> Repository branch: master
> Windowing system distributor 'The X.Org Foundation', version 11.0.12101001
> System Description: Ubuntu 21.04
> 
> Configured features:
> CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON
> LCMS2 LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG
> RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM
> GTK3 ZLIB
> 
> Important settings:
>   value of $LANG: en_US.UTF-8
>   value of $XMODIFIERS: @im=ibus
>   locale-coding-system: utf-8-unix
> 
> Major mode: C/*l
> 
> Minor modes in effect:
>   bug-reference-prog-mode: t
>   tooltip-mode: t
>   global-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
>   abbrev-mode: t
> 
> Load-path shadows:
> None found.
> 
> Features:
> (shadow sort mail-extr emacsbug message rmc puny 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 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-git diff-mode easy-mmode vc
> vc-dispatcher bug-reference cc-mode cc-fonts cc-guess cc-menus cc-cmds
> cc-styles cc-align cc-engine cc-vars cc-defs misearch multi-isearch
> dired-aux dired dired-loaddefs time-date subr-x cl-extra seq byte-opt gv
> bytecomp byte-compile cconv kmacro two-column help-mode 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 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 dbusbind
> inotify lcms2 dynamic-setting system-font-setting font-render-setting
> cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)
> 
> Memory information:
> ((conses 16 118009 7881)
>  (symbols 48 9308 1)
>  (strings 32 27924 2053)
>  (string-bytes 1 1038142)
>  (vectors 16 18491)
>  (vector-slots 8 227657 9510)
>  (floats 8 31 163)
>  (intervals 56 10630 0)
>  (buffers 992 14))
> 
> 


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48812; Package emacs. (Thu, 03 Jun 2021 17:16:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Naofumi Yasufuku <naofumi <at> yasufuku.dev>
Cc: 48812 <at> debbugs.gnu.org
Subject: Re: bug#48812: 28.0.50;
 describe-bindings stucks and gets high CPU load
Date: Thu, 03 Jun 2021 20:15:19 +0300
merge 48812 45379
thanks

> From: Naofumi Yasufuku <naofumi <at> yasufuku.dev>
> Date: Fri, 4 Jun 2021 00:06:55 +0900
> 
> This describe-bindings stuck is caused by millions of shadow_lookup() calls
> in src/keymap.c describe_vector().

This is a duplicate of bug#45379.




Merged 45379 47494 47565 48812. Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 03 Jun 2021 17:16:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48812; Package emacs. (Thu, 03 Jun 2021 17:53:02 GMT) Full text and rfc822 format available.

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

From: Naofumi Yasufuku <naofumi <at> yasufuku.dev>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 48812 <at> debbugs.gnu.org
Subject: Re: bug#48812: 28.0.50; describe-bindings stucks and gets high CPU
 load
Date: Fri, 4 Jun 2021 02:52:18 +0900
Thanks. I’m sorry for bothering you.
I found bug#45379. It looks really complicated...


> On Jun 4, 2021, at 2:15, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
> merge 48812 45379
> thanks
> 
>> From: Naofumi Yasufuku <naofumi <at> yasufuku.dev>
>> Date: Fri, 4 Jun 2021 00:06:55 +0900
>> 
>> This describe-bindings stuck is caused by millions of shadow_lookup() calls
>> in src/keymap.c describe_vector().
> 
> This is a duplicate of bug#45379.





Added tag(s) fixed. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sat, 18 Sep 2021 14:40:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 45379 <at> debbugs.gnu.org and styang <at> fastmail.com Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sat, 18 Sep 2021 14:40:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 17 Oct 2021 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 163 days ago.

Previous Next


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