From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id 20F013858C78 for ; Fri, 17 Feb 2023 01:00:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 20F013858C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id 75B2E10043685 for ; Fri, 17 Feb 2023 01:00:19 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id Sp6ppysVfNX2aSp6ppj2gP; Fri, 17 Feb 2023 01:00:19 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63eed1a3 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=m04uMKEZRckA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=CCpqsmhAAAAA:8 a=mDV3o1hIAAAA:8 a=uWX6QWOKjYWtA4pYIaIA:9 a=QEXdDO2ut3YA:10:nop_charset_2 a=ul9cdbp4aOFLsgKbc677:22 a=_FVE-zBwftR9WsbkzFJk:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=UxvNUqb30jRcgebhwg1ETnrC8VXDdqN1+H+LD3F63Is=; b=nC3SzzoF7YshuhBYib6f+RhuWd eSYDKcOprGX1CSDRohoKYSYvTfXrkluUXnClV8zYQGX5Tprr8Mk3LKIk/N+P158YxXw35xlmipQFR fx9OeqmBh2D0OL10YXuk01aXw; Received: from c-98-245-160-18.hsd1.co.comcast.net ([98.245.160.18]:33030 helo=[192.168.0.59]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pSp6p-000gn4-5C for gdb-patches@sourceware.org; Thu, 16 Feb 2023 18:00:19 -0700 From: Tom Tromey Date: Thu, 16 Feb 2023 18:00:13 -0700 Subject: [PATCH 2/2] Fix crash in go_symbol_package_name MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230216-submit-go-unique-ptr-v1-2-73dd8065c6a6@tromey.com> References: <20230216-submit-go-unique-ptr-v1-0-73dd8065c6a6@tromey.com> In-Reply-To: <20230216-submit-go-unique-ptr-v1-0-73dd8065c6a6@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 98.245.160.18 X-Source-L: No X-Exim-ID: 1pSp6p-000gn4-5C X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: c-98-245-160-18.hsd1.co.comcast.net ([192.168.0.59]) [98.245.160.18]:33030 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: go_symbol_package_name package name asserts that it is only passed a Go symbol, but this is not enforced by one caller. It seems simplest to just check and return early in this case. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17876 --- gdb/go-lang.c | 3 ++- gdb/testsuite/gdb.go/no-package.exp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gdb/go-lang.c b/gdb/go-lang.c index f9176ace71d..bbf80af1f5c 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -394,7 +394,8 @@ go_symbol_package_name (const struct symbol *sym) int method_type_is_pointer; gdb::unique_xmalloc_ptr name_buf; - gdb_assert (sym->language () == language_go); + if (sym->language () != language_go) + return nullptr; name_buf = unpack_mangled_go_symbol (mangled_name, &package_name, &object_name, &method_type_package_name, diff --git a/gdb/testsuite/gdb.go/no-package.exp b/gdb/testsuite/gdb.go/no-package.exp new file mode 100644 index 00000000000..3b39bc3220d --- /dev/null +++ b/gdb/testsuite/gdb.go/no-package.exp @@ -0,0 +1,31 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2023 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Regression test for a crash in go_symbol_package_name. + +load_lib "go.exp" + +require allow_go_tests support_go_compile !use_gdb_stub + +standard_testfile integers.go + +if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug go}]} { + return -1 +} + +# The bug was that stopping in _start would crash. +runto "*_start" message -- 2.39.1