all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Xinyang Chen <chenxy@mit.edu>, Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 62867@debbugs.gnu.org
Subject: bug#62867: segfault in describe_vector
Date: Sat, 15 Apr 2023 22:33:03 +0300	[thread overview]
Message-ID: <83y1mtaqkw.fsf@gnu.org> (raw)
In-Reply-To: <CAKGiUYwWCt-jMjz=cBvT91T-kwVsQ_09s4j8R0HDxsTwXn4SYQ@mail.gmail.com> (message from Xinyang Chen on Sat, 15 Apr 2023 08:07:07 -0400)

> From: Xinyang Chen <chenxy@mit.edu>
> Date: Sat, 15 Apr 2023 08:07:07 -0400
> 
> to reproduce:
> 
> (package-initialize)
> (require 'evil)
> (setq testmap (make-sparse-keymap))
> (define-key testmap (kbd "SPC") #'test)
> (evil-define-key 'motion global-map (kbd "SPC") testmap)
> (evil-mode)
> (describe-keymap global-map)
> 
> This appears to be caused by keymap.c line 3313
> SYMBOL_NAME (shadowed_by)
> where shadowed_by don't have to be a symbol (In this case its a keymap)

No good deed goes unpunished...

Stefan, can we do better than the below?

diff --git a/src/keymap.c b/src/keymap.c
index efac410..b9950b9 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -3308,13 +3308,18 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
       if (this_shadowed)
 	{
 	  SET_PT (PT - 1);
-	  static char const fmt[] = "  (currently shadowed by `%s')";
-	  USE_SAFE_ALLOCA;
-	  char *buffer = SAFE_ALLOCA (sizeof fmt +
-				      SBYTES (SYMBOL_NAME (shadowed_by)));
-	  esprintf (buffer, fmt, SDATA (SYMBOL_NAME (shadowed_by)));
-	  insert_string (buffer);
-	  SAFE_FREE();
+	  if (SYMBOLP (shadowed_by))
+	    {
+	      static char const fmt[] = "  (currently shadowed by `%s')";
+	      USE_SAFE_ALLOCA;
+	      char *buffer =
+		SAFE_ALLOCA (sizeof fmt + SBYTES (SYMBOL_NAME (shadowed_by)));
+	      esprintf (buffer, fmt, SDATA (SYMBOL_NAME (shadowed_by)));
+	      insert_string (buffer);
+	      SAFE_FREE();
+	    }
+	  else
+	    insert_string ("  (binding currently shadowed by a keymap)");
 	  SET_PT (PT + 1);
 	}
     }





  reply	other threads:[~2023-04-15 19:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-15 12:07 bug#62867: segfault in describe_vector Xinyang Chen
2023-04-15 19:33 ` Eli Zaretskii [this message]
2023-04-15 22:16   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16  5:53     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83y1mtaqkw.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=62867@debbugs.gnu.org \
    --cc=chenxy@mit.edu \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.