From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#62867: segfault in describe_vector Date: Sat, 15 Apr 2023 18:16:32 -0400 Message-ID: References: <83y1mtaqkw.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34858"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 62867@debbugs.gnu.org, Xinyang Chen To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 16 00:17:36 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 1pnoD9-0008uI-Ky for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Apr 2023 00:17:35 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnoCv-0006W8-15; Sat, 15 Apr 2023 18:17:21 -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 1pnoCs-0006Vl-A5 for bug-gnu-emacs@gnu.org; Sat, 15 Apr 2023 18:17:18 -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 1pnoCc-0007hX-9n for bug-gnu-emacs@gnu.org; Sat, 15 Apr 2023 18:17:15 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pnoCb-0007Xj-J2 for bug-gnu-emacs@gnu.org; Sat, 15 Apr 2023 18:17:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Apr 2023 22:17:01 +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.168159700228957 (code B ref 62867); Sat, 15 Apr 2023 22:17:01 +0000 Original-Received: (at 62867) by debbugs.gnu.org; 15 Apr 2023 22:16:42 +0000 Original-Received: from localhost ([127.0.0.1]:50254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pnoCI-0007Wy-D3 for submit@debbugs.gnu.org; Sat, 15 Apr 2023 18:16:42 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:23002) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pnoCG-0007Wl-Q8 for 62867@debbugs.gnu.org; Sat, 15 Apr 2023 18:16:41 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 46DC5806BB; Sat, 15 Apr 2023 18:16:35 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 3E32380496; Sat, 15 Apr 2023 18:16:34 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1681596994; bh=48jxHF1Nq4E3x7j6G3RvfEeUX5AVWszdUnIu022CNxA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=lgqg/WH0rEHBUWhPgv6S00a0YWsQjiHQn+b6w2hJf839tXQ9EksSDRb5MFkLH/m+B KGSF/4bsNnXizbaDtKnP2KHL6OHnmy/fMlJdbiv7ws5LY5EIsLbMsoeEVGyVASKV2f ZaHB+beYI1bl0IRyAdSv1LlW0IrmMbIy4oR24iWGsJ1skhUuTjnzWbig8CUzvrEuMQ jojLHiHE9zZYAZDHVOEe5v7ltamyA6cL6+pHKFZneElEgWeb04ImN/Uemid14oZZbd 4rQouzmKq60bszSyG9hqcxPkPgTi+bsBS182+EHh6+4qPzh2gz2EM8fDwHcbCHH5Ba +vOrHWLkn0Kmg== Original-Received: from pastel (unknown [45.72.217.176]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9C25B1202DB; Sat, 15 Apr 2023 18:16:33 -0400 (EDT) In-Reply-To: <83y1mtaqkw.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 15 Apr 2023 22:33:03 +0300") 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:260080 Archived-At: > Stefan, can we do better than the below? The patch looks about right to me. Only detail is that `shadowed_by` contains a binding, so it can be a keymap, but it can also be a lambda expression, or a keyboard macro, so we shouldn't say "shadowed by a keymap" but just "shadowed" (unless we go through the extra trouble of checking if it's a keymap, or if it's a ...). Stefan > 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); > } > }