From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#62867: segfault in describe_vector Date: Sat, 15 Apr 2023 22:33:03 +0300 Message-ID: <83y1mtaqkw.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11675"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62867@debbugs.gnu.org To: Xinyang Chen , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 15 21:34:30 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pnlfJ-0002lZ-H0 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 15 Apr 2023 21:34:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnlev-0000qw-1T; Sat, 15 Apr 2023 15:34:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnlet-0000qV-AZ for bug-gnu-emacs@gnu.org; Sat, 15 Apr 2023 15:34:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnlet-0003d7-2c for bug-gnu-emacs@gnu.org; Sat, 15 Apr 2023 15:34:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pnles-00034B-G7 for bug-gnu-emacs@gnu.org; Sat, 15 Apr 2023 15:34:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Apr 2023 19:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62867 X-GNU-PR-Package: emacs Original-Received: via spool by 62867-submit@debbugs.gnu.org id=B62867.168158719311723 (code B ref 62867); Sat, 15 Apr 2023 19:34:02 +0000 Original-Received: (at 62867) by debbugs.gnu.org; 15 Apr 2023 19:33:13 +0000 Original-Received: from localhost ([127.0.0.1]:50183 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pnle4-000331-LD for submit@debbugs.gnu.org; Sat, 15 Apr 2023 15:33:12 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58592) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pnle1-00032j-U7 for 62867@debbugs.gnu.org; Sat, 15 Apr 2023 15:33:11 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnldv-0003Xx-9T; Sat, 15 Apr 2023 15:33:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=k7czpJEyKqWEVidxzLFmuh7G32Sj1/biJzvmrNMXgSc=; b=rnpnvIX5Y+XK zArq3yQLP1pTwO3s5hnuAn234V3L9zwZMX4FU1m2ylbTcUmmqBsKi963bGhXRpMkq6k/zOaQ1lJ0n jtSPTJDKp93nSdM9bZDvaeA70EwoqrORBszHaAoJ8omz+ezacpKbJZrZI5UMfMa6yGRpblMWxKaxs CTfQCj20kw0eelKZNfsR+MabayH9OHTh65mqZrw23h8lgT9APUQ76u3+SQowC2YYL1ACYq1WTKW11 BGPbMFvcIGJOxGab5uvdyVeOz1lprdfm5WaIipzHv6G4b2Qj+ZP5FBE7CUbDbYb5nL/J7R4wNC3E9 uU1b4AqZfXQbuNzq/J1RPg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnldu-0006nC-Hk; Sat, 15 Apr 2023 15:33:02 -0400 In-Reply-To: (message from Xinyang Chen on Sat, 15 Apr 2023 08:07:07 -0400) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:260075 Archived-At: > From: Xinyang Chen > 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); } }