From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id gs48EwuV12pzDTsAWB0awg (envelope-from ) for ; Tue, 20 Oct 2026 12:21:31 -0400 Received: by simark.ca (Postfix, from userid 112) id F06EE1E04D; Tue, 20 Oct 2026 12:21:30 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id BD9CE1E04D for ; Tue, 20 Oct 2026 12:21:25 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DFD834A9BE7D for ; Tue, 20 Oct 2026 16:21:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFD834A9BE7D Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id CDA3A4A9C01E for ; Tue, 20 Oct 2026 16:20:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CDA3A4A9C01E Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CDA3A4A9C01E Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792513259; cv=none; b=BMq6/cRFajtI0yiyQLLbkQfQ7FksA8bexLqQY5J499juktOW7LmgudmHASx1LsZz7S0vDYS/mTwpB3DeAeN/heyXoEsG9BgnZ1wPCFWssXdn6tkhwDQYnyR2MnO4agg5Ost6lD5B7e4m6bnv7blG+OcT34J+SYs/Tx4hZIJAikU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792513259; c=relaxed/simple; bh=P4eHhuQjKQnVniuwvI/saiaJW6jQm91xSZsOw+o+ihg=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=MTJdVlfCObAJQwUN9JAU/vL507tOFbDeCOrFSc8yswJOupnYqKrNW6ZiGH/ID+r/PKp421/y6u6qYlSAjZ+TIESDBW8GfWt5jwSjKu6Ft/XukKeI8yvt8yNNYtxUUYgGfxiBJXjsAmTY6MIGdTS0kA5pKM4HQooakPrm//cRS/U= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CDA3A4A9C01E Received: by simark.ca (Postfix) id 2CD661E090; Tue, 20 Oct 2026 12:20:58 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 04/13] gdb: fix crash in "maint canonicalize" without argument Date: Tue, 20 Oct 2026 12:17:26 -0400 Message-ID: <20261020162054.2140671-5-simon.marchi@efficios.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261020162054.2140671-1-simon.marchi@efficios.com> References: <20261020162054.2140671-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Running "maint canonicalize" without an argument crashes GDB: $ ./gdb -nx -q --data-directory=data-directory -ex "maint canon" -batch /home/smarchi/src/binutils-gdb/gdb/cp-support.c:105:27: runtime error: load of null pointer of type 'const char' This message is from UBSan, otherwise we get a segfault. maintenance_canonicalize passes the NULL ARGS straight to cp_canonicalize_string. Error out with error_no_arg if no argument is given. Add a test in gdb.base/maint.exp. Change-Id: I2924a6e8d2a0a5ea77bdee5595a75c8c0fb59673 --- gdb/maint.c | 3 +++ gdb/testsuite/gdb.base/maint.exp | 1 + 2 files changed, 4 insertions(+) diff --git a/gdb/maint.c b/gdb/maint.c index 22954f624efe..7864458ba136 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -118,6 +118,9 @@ maintenance_demangle (const char *args, int from_tty) static void maintenance_canonicalize (const char *args, int from_tty) { + if (args == nullptr) + error_no_arg (_("name")); + gdb::unique_xmalloc_ptr canon = cp_canonicalize_string (args); if (canon == nullptr) gdb_printf ("No change.\n"); diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp index f0c183c8c417..d13dab21fbe9 100644 --- a/gdb/testsuite/gdb.base/maint.exp +++ b/gdb/testsuite/gdb.base/maint.exp @@ -456,5 +456,6 @@ gdb_test "maint canonicalize int short" "canonical = short" gdb_test "maint canonicalize fn>" \ "canonical = fn >" gdb_test "maint canonical unsigned int" "No change\\." +gdb_test "maint canonicalize" "Argument required \\(name\\)\\." gdb_exit -- 2.56.0