From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UFVrDemF6WI9Tx8AWB0awg (envelope-from ) for ; Tue, 02 Aug 2022 16:15:37 -0400 Received: by simark.ca (Postfix, from userid 112) id 323EE1EA05; Tue, 2 Aug 2022 16:15:37 -0400 (EDT) Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=O8lbj+ST; 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=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.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 95A811EA03 for ; Tue, 2 Aug 2022 16:15:36 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 48DAC3852758 for ; Tue, 2 Aug 2022 20:15:36 +0000 (GMT) Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id AC5783858031 for ; Tue, 2 Aug 2022 20:15:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AC5783858031 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 cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id A1C50100471FA for ; Tue, 2 Aug 2022 20:15:02 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IyIAojHUMWg0EIyIAohkJC; Tue, 02 Aug 2022 20:15:02 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Y4w9DjSN c=1 sm=1 tr=0 ts=62e985c6 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=biHskzXt2R4A:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=tr9WYyuZtgKgMl8v-TQA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=2X+zc4wUKnhns/NBQyK+Pt/7fU10AvYERnnkp4VI7AA=; b=O8lbj+STLif7lr8j2lbnbLNQC6 tUw7LqBvIuR/hTSTN/G4s5bnjo1m0FOJy22UQCrTyug/UPmhk69tM6V/HK0IAA1VIs9pjh8+UXQxz pSQEODCTh0pjHrZ4qyx++RkpO; Received: from 71-211-185-228.hlrn.qwest.net ([71.211.185.228]:45458 helo=prentzel.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oIyI9-0009ye-QK; Tue, 02 Aug 2022 14:15:01 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 2/3] Use auto_obstack in objfile Date: Tue, 2 Aug 2022 14:14:58 -0600 Message-Id: <20220802201459.2839634-3-tom@tromey.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220802201459.2839634-1-tom@tromey.com> References: <20220802201459.2839634-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 71.211.185.228 X-Source-L: No X-Exim-ID: 1oIyI9-0009ye-QK X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-185-228.hlrn.qwest.net (prentzel.Home) [71.211.185.228]:45458 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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: , Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" This changes objfile to use an auto_obstack. This helps prevent use-after-free bugs, because it ensures that anything allocated on the objfile obstack will live past the point at which the registry object is destroyed. --- gdb/objfiles.c | 7 ------- gdb/objfiles.h | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 3db9135a64b..c92da7548b3 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -324,10 +324,6 @@ objfile::objfile (gdb_bfd_ref_ptr bfd_, const char *name, objfile_flags flags_) { const char *expanded_name; - /* We could use obstack_specify_allocation here instead, but - gdb_obstack.h specifies the alloc/dealloc functions. */ - obstack_init (&objfile_obstack); - std::string name_holder; if (name == NULL) { @@ -583,9 +579,6 @@ objfile::~objfile () clear_current_source_symtab_and_line (); } - /* Free the obstacks for non-reusable objfiles. */ - obstack_free (&objfile_obstack, 0); - /* Rebuild section map next time we need it. */ get_objfile_pspace_data (pspace)->section_map_dirty = 1; } diff --git a/gdb/objfiles.h b/gdb/objfiles.h index eb85ed478c6..ac45fa3980f 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -666,7 +666,7 @@ struct objfile /* Obstack to hold objects that should be freed when we load a new symbol table from this object file. */ - struct obstack objfile_obstack {}; + auto_obstack objfile_obstack; /* Structure which keeps track of functions that manipulate objfile's of the same type as this objfile. I.e. the function to read partial -- 2.34.1