From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id EEB20385828E for ; Fri, 17 Feb 2023 22:51:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EEB20385828E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676674292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AxrgyEJnU7REVV8RD4P6s6AMv00LAJmSgZ24Gss09m8=; b=WYtWfvmzSRTdKjw4ncOG0gJdC9BZSAZU7o6VW21xWhCrhkGVp/mIkBGmOaXjMq77LCShsT J7V2KRVnxWjBWAMIzMADY1gU/FVZ6gVW9cqn7FSXVgJyA0ovOXbu5LQJbv5gE3LkRyuEqe hfUFDd3/VZb93iugRivnsVcbLNloV44= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-517-RT4XVJJkPNqSib3Jmm-0lw-1; Fri, 17 Feb 2023 17:51:31 -0500 X-MC-Unique: RT4XVJJkPNqSib3Jmm-0lw-1 Received: by mail-wm1-f71.google.com with SMTP id m40-20020a05600c3b2800b003dc5cb10dcfso1283551wms.9 for ; Fri, 17 Feb 2023 14:51:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AxrgyEJnU7REVV8RD4P6s6AMv00LAJmSgZ24Gss09m8=; b=UYy3fQHh3EXACWxXb6hhrC4XRYuNNpsE5/XFi5QQ/HC+92uwh5iyDLD72Xsq/8Cz81 CITkNNckppukjw4eyb+jidh+B+BmEQfoJPBWIXQczKtW2keSAJyWr0WD5XG7IihuPm1/ /HsBACr5lXqEh8e5Jw5tmvrJ6NVAEzGNoopakmHofWLlAud23JhUd4yo1SPyGxMHx6rp s9fDDNYEmQX9E0QjCLsSJJj/psiGzxa9zrODJ5ncXnh9Sd7a31XSrKThk2NtGGjiXkV0 rOSYJrbXvP23inN/dNpdDuPJxJkJ7fW6UOZABwgng0mHcNW14CPGWLef7VAlfpfz7o4+ yqEA== X-Gm-Message-State: AO0yUKWR9/BvtpWln41iHqaC4wzG9ilTUPuEV7JDLspcP6WaBK1RPq/t YGFonH49BG17cByUt3aN8UUjbOHrqQhp44Juxaz2WfyI/z/lkpQOMkryoqw27RedZp9LUPbRrrd Ug2ZPI923QKYi7S62CrYt19BVtPs= X-Received: by 2002:adf:ef8f:0:b0:2bf:ee7d:5369 with SMTP id d15-20020adfef8f000000b002bfee7d5369mr1222846wro.59.1676674290244; Fri, 17 Feb 2023 14:51:30 -0800 (PST) X-Google-Smtp-Source: AK7set9sdNz0hLwiIc3bpnh+rtVl2jWAo+hPAqYcM3tMoZAu214ntWssv4XZk/3eHWJLr6Qq87tm1g== X-Received: by 2002:adf:ef8f:0:b0:2bf:ee7d:5369 with SMTP id d15-20020adfef8f000000b002bfee7d5369mr1222838wro.59.1676674289902; Fri, 17 Feb 2023 14:51:29 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id k9-20020adfd849000000b002c3f50228afsm5215101wrl.3.2023.02.17.14.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Feb 2023 14:51:29 -0800 (PST) From: Andrew Burgess To: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [PATCH 2/2] Fix crash in go_symbol_package_name In-Reply-To: <20230216-submit-go-unique-ptr-v1-2-73dd8065c6a6@tromey.com> References: <20230216-submit-go-unique-ptr-v1-0-73dd8065c6a6@tromey.com> <20230216-submit-go-unique-ptr-v1-2-73dd8065c6a6@tromey.com> Date: Fri, 17 Feb 2023 22:51:28 +0000 Message-ID: <87bklrlxcf.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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: Tom Tromey writes: > 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; I think the comment for this function in go-lang.h can be updated. The comment claims that this function takes a Go symbol, when we now take any symbol. Looks fine with that updated. Reviewed-By: Andrew Burgess Thanks, Andrew > 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