From patchwork Fri Oct 18 00:02:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 99111 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 180BA3858C2B for ; Fri, 18 Oct 2024 00:04:40 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id 8C5EC3858C42 for ; Fri, 18 Oct 2024 00:02:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8C5EC3858C42 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8C5EC3858C42 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729209793; cv=none; b=gRyXh5neQtD1sFa4F68zWZJ1N8pQxk7KXiVcR4HPNwUbqADA5tmjhpPpqcYu7HfhcBoULFW8X/wrvtxcWu3OcZws91W/0hxm+ZBUDCe+CRD49aXw5v8i8836at58iCrv7VvaAbTnRk5qBn8NcSaqfLaTW+vi18n9X6+cr20ta5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729209793; c=relaxed/simple; bh=982FfJwFXlD24WTsla7eCnsn6Tj5684k85EzAO40zC8=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=I8LQzL0JP0JHQG4pUX1kvXFlRsW5aLs2uT6EAeu1esgiS9IsX872IC/7PITEvbmTH7uZb32dfIyAxRxVzSofCskxmHNQAXfK7BtukCbvhdRxXHnKLHG6f3cDGLh5EMhIDTMCbh0cQQF+MKgTNfmH5OiGPjP0L+mzXt2aU3u8EYg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6004a.ext.cloudfilter.net ([10.0.30.197]) by cmsmtp with ESMTPS id 1TXCtinCavH7l1aS2t948Z; Fri, 18 Oct 2024 00:02:42 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 1aS0tH7ytWdNZ1aS1tCGHg; Fri, 18 Oct 2024 00:02:41 +0000 X-Authority-Analysis: v=2.4 cv=FtTO/Hrq c=1 sm=1 tr=0 ts=6711a5a1 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=DAUX931o1VcA:10 a=ItBw4LHWJt0A:10 a=Gnwpio9NvWRAsuPnYAsA:9 a=QEXdDO2ut3YA:10 a=6Ogn3jAGHLSNbaov7Orx: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=inHRy4To0F8UJWzZ29fwdtTARAYB1Vy3vMFiZfoO70Q=; b=F1aqzavO+NJ0KJAVrrhipSxfbb WA1wFk6PHnUfGRZ/5jMH4PWPvZBF9efoDnp0CWzFZJ6sAi52snZIwuYJQudJR5lel1LeEU+0T1/oF ZBROhhybXGOhNpRRvDMeEwjEt; Received: from c-67-190-86-1.hsd1.co.comcast.net ([67.190.86.1]:50290 helo=prentzel.local) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1t1aS0-0025wO-2A for gdb-patches@sourceware.org; Thu, 17 Oct 2024 18:02:40 -0600 From: Tom Tromey Date: Thu, 17 Oct 2024 18:02:37 -0600 Subject: [PATCH 1/2] Use gdb_bfd_get_full_section_contents in auto-load.c MIME-Version: 1.0 Message-Id: <20241017-fix-race-pr-symtab-31626-v1-1-3a53459e9651@tromey.com> References: <20241017-fix-race-pr-symtab-31626-v1-0-3a53459e9651@tromey.com> In-Reply-To: <20241017-fix-race-pr-symtab-31626-v1-0-3a53459e9651@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.14.2 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: 67.190.86.1 X-Source-L: No X-Exim-ID: 1t1aS0-0025wO-2A X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: c-67-190-86-1.hsd1.co.comcast.net (prentzel.local) [67.190.86.1]:50290 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfAaMrIYA4UT/KfyrW11C/36wWPLsN3/VjWTxp4TN9HnCqNp3m2kKBlMiuEdOkMpnuAwv+fbZymVpBI2BZ0+a0Ltp9TQ9OMI6wu+4v9xzr94HkyddQmfW U6btSWhxVa8Q0So9h6AuLRlPjs97NMG3JIwlM0YWP/BaWmyIHKvrwAuVw4kIxkaaOhsEyirZGuBR90MdQ537EBLJrIoyuZiL5zI= X-Spam-Status: No, score=-3018.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_BL_SPAMCOP_NET, 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 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~patchwork=sourceware.org@sourceware.org This changes auto-load.c ot use gdb_bfd_get_full_section_contents. This shouldn't change any behavior, but makes it easier to add locking in a subsequent patch. --- gdb/auto-load.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gdb/auto-load.c b/gdb/auto-load.c index e753333b1cdfe6a12b1885d1468ef92ef51776af..d4307eac6273803ed7024491169701e8a55fcc6b 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -1114,25 +1114,22 @@ auto_load_section_scripts (struct objfile *objfile, const char *section_name) { bfd *abfd = objfile->obfd.get (); asection *scripts_sect; - bfd_byte *data = NULL; scripts_sect = bfd_get_section_by_name (abfd, section_name); if (scripts_sect == NULL || (bfd_section_flags (scripts_sect) & SEC_HAS_CONTENTS) == 0) return; - if (!bfd_get_full_section_contents (abfd, scripts_sect, &data)) + gdb::byte_vector data; + if (!gdb_bfd_get_full_section_contents (abfd, scripts_sect, &data)) warning (_("Couldn't read %s section of %ps"), section_name, styled_string (file_name_style.style (), bfd_get_filename (abfd))); else { - gdb::unique_xmalloc_ptr data_holder (data); - - char *p = (char *) data; - source_section_scripts (objfile, section_name, p, - p + bfd_section_size (scripts_sect)); + const char *p = (const char *) data.data (); + source_section_scripts (objfile, section_name, p, p + data.size ()); } }