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 D66033858D1E for ; Wed, 3 May 2023 00:33:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D66033858D1E 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=1683073995; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z6c9Jc/xHelFGHDFmvsIgrj7rorDVaitfhpvIGsW3Vc=; b=LuhHEiD83OwGBRJiXnQglg9kvdz0L3HcH1/AGlrUmxKyrTjMYueVCmCegM51L4wtTlCPPN 1dnqFHtyzpUPrB714VAEQ0onH9zpQNAEv4eBCT9gw+JAf1OPTdwXNU7o/QQ979oKA/Rg8V Gf76Nkj1BRxi0RAxRzU3c9RONEpjw44= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-9O7Ikv4rMN-tyete_2iCgg-1; Tue, 02 May 2023 20:33:12 -0400 X-MC-Unique: 9O7Ikv4rMN-tyete_2iCgg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0DE2D185A78B; Wed, 3 May 2023 00:33:12 +0000 (UTC) Received: from f37-zws-nv (unknown [10.22.10.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9808A1121331; Wed, 3 May 2023 00:33:11 +0000 (UTC) Date: Tue, 2 May 2023 17:33:09 -0700 From: Kevin Buettner To: Mark Wielaard Cc: gdb-patches@sourceware.org, Tom Tromey Subject: Re: [PATCH] Pass const frame_info_ptr reference for skip_[language_]trampoline Message-ID: <20230502173309.764aae3c@f37-zws-nv> In-Reply-To: <20230502183444.1445634-1-mark@klomp.org> References: <20230502183444.1445634-1-mark@klomp.org> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: Hi Mark, On Tue, 2 May 2023 20:34:44 +0200 Mark Wielaard wrote: > g++ 13.1.1 produces a -Werror=dangling-pointer= > > In file included from ../../binutils-gdb/gdb/frame.h:75, > from ../../binutils-gdb/gdb/symtab.h:40, > from ../../binutils-gdb/gdb/language.c:33: > In member function ___void intrusive_list::push_empty(T&) [with T = frame_info_ptr; AsNode = intrusive_base_node]___, > inlined from ___void intrusive_list::push_back(reference) [with T = frame_info_ptr; AsNode = intrusive_base_node]___ at gdbsupport/intrusive_list.h:332:24, > inlined from ___frame_info_ptr::frame_info_ptr(const frame_info_ptr&)___ at gdb/frame.h:241:26, > inlined from ___CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)___ at gdb/language.c:530:49: > gdbsupport/intrusive_list.h:415:12: error: storing the address of local variable ______ in ___frame_info_ptr::frame_list.intrusive_list::m_back___ [-Werror=dangling-pointer=] > 415 | m_back = &elem; > | ~~~~~~~^~~~~~~ > gdb/language.c: In function ___CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)___: > gdb/language.c:530:49: note: ______ declared here > 530 | CORE_ADDR real_pc = lang->skip_trampoline (frame, pc); > | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ > gdb/frame.h:359:41: note: ___frame_info_ptr::frame_list___ declared here > 359 | static intrusive_list frame_list; > | ^~~~~~~~~~ > > Each new frame_info_ptr is being pushed on a static frame list and g++ > cannot see why that is safe in case the frame_info_ptr is created and > destroyed immediately when passed as value. > > It isn't clear why only in this one place g++ sees the issue (probably > because it can inlined enough code in this specific case). > > Since passing the frame_info_ptr as const reference is cheaper, use > that as workaround for this warning. I've tested your patch on Fedora 38 w/ gcc (GCC) 13.1.1 20230426 (Red Hat 13.1.1-1) and find that GDB builds again. Currently, it doesn't build without your patch. Your explanation and fix looks reasonable to me too. Tested-by: Kevin Buettner Reviewed-by: Kevin Buettner