From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2IBNCuOrUWQfQj0AWB0awg (envelope-from ) for ; Tue, 02 May 2023 20:33:39 -0400 Received: by simark.ca (Postfix, from userid 112) id 1ED331E11B; Tue, 2 May 2023 20:33:39 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=VnK6c1qA; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id AEF9E1E0D3 for ; Tue, 2 May 2023 20:33:38 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E4EC23858423 for ; Wed, 3 May 2023 00:33:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E4EC23858423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683074017; bh=Z6c9Jc/xHelFGHDFmvsIgrj7rorDVaitfhpvIGsW3Vc=; h=Date:To:Cc:Subject:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=VnK6c1qAdStaOLBRuBtyC/gP8rvRWHibpydyI3UEj4yPPhq3aOaGcC/sTYTBp3jlg RvzFAFrJAGUYxqAwmsl3WZz8OQHSB9g9470Bq+Rl7xJ9dto+4gQVDyC8eobek/AYY6 2PQba9Zz9UXBfQQyyOWRpkaMyiqdPetJJT6rvRl0= 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 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 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-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Kevin Buettner via Gdb-patches Reply-To: Kevin Buettner Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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