From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cWXbAw1k+mgFxAQAWB0awg (envelope-from ) for ; Thu, 23 Oct 2025 13:21:17 -0400 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=wlsF2MFr; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 09E321E0BC; Thu, 23 Oct 2025 13:21:17 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no autolearn_force=no version=4.0.1 Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8E8521E04C for ; Thu, 23 Oct 2025 13:21:16 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1D2603858424 for ; Thu, 23 Oct 2025 17:21:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D2603858424 Authentication-Results: sourceware.org; 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=wlsF2MFr Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 3C50F3858422 for ; Thu, 23 Oct 2025 17:18:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3C50F3858422 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 3C50F3858422 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761239899; cv=none; b=cdfWgQger8PxMProk8A4MKIX4GG1PxyXCaXm9Cm7F17+jtyt9pihgEOCFKjhkupk/Zs49xxqnhTlt0GsV+gJTjR9cDybS/W438TVljGfhFjDLlnpC2yxRf0sJ1uM/jwBD7de3raWvFjXf/heWBn3AQftNyxSFzF2nS8jvo5OGAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761239899; c=relaxed/simple; bh=BLu+4988ft2ThC4Bd5dxnfgCvvIAQeDYaFnSAubNW9I=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=hrAPc0MigH3AZgKnYAZ77xJjhPTHHytXaJ4e1FHkSfNzqwsFNSsKhvtrG4PFEu+Mn9T5L+ytc+tQoExtI+2sdQJ5UkHnTZDgXPfIc6blBSH7sUmdBDe5kLav+WtBlbk+uUszF0Bu9BhzSeYjQDdpdtIreUM1sqAftchyEWJBZZE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C50F3858422 Received: from eig-obgw-5007b.ext.cloudfilter.net ([10.0.29.167]) by cmsmtp with ESMTPS id Ba8ovs8XvZx2iByx8vrLMM; Thu, 23 Oct 2025 17:18:18 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id BywRvTZ6NFPddBywSvbZk7; Thu, 23 Oct 2025 17:17:36 +0000 X-Authority-Analysis: v=2.4 cv=OphPyz/t c=1 sm=1 tr=0 ts=68fa635a a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=x6icFKpwvdMA:10 a=ItBw4LHWJt0A:10 a=V_nkiiP73s61oex73QcA:9 a=QEXdDO2ut3YA:10 a=VS4QxaUSPT0UtbFnIvSC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To: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=wwz3X6maGzWPuGiL/gnbNgpApCJNSruAHMEi7sofExc=; b=wlsF2MFrccNmATqztRAG4IbVX8 zFQ6NjmI9Eskaa5zPFWNTM0zMplsV7OUS4rc5yww9DMsXGBP88nxbSlZtVpM5xa4/GiJbsD18xI/+ lDaMEudJCps2kwIHdnHceIWve; Received: from 97-122-110-68.hlrn.qwest.net ([97.122.110.68]:33134 helo=[192.168.0.17]) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vBywR-00000002lTI-26MK; Thu, 23 Oct 2025 11:17:35 -0600 From: Tom Tromey Date: Thu, 23 Oct 2025 11:17:34 -0600 Subject: [PATCH 2/2] Free multidicts from blockvector MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20251023-mdict-free-v1-2-ad02b2bdd549@tromey.com> References: <20251023-mdict-free-v1-0-ad02b2bdd549@tromey.com> In-Reply-To: <20251023-mdict-free-v1-0-ad02b2bdd549@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey 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: 97.122.110.68 X-Source-L: No X-Exim-ID: 1vBywR-00000002lTI-26MK X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-110-68.hlrn.qwest.net ([192.168.0.17]) [97.122.110.68]:33134 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfLTxn+KtwVvFcGhfta3N88JxfJa2HlBbYSygx28n5N3GlZzbdI2ZCW3hvFO71ygom4of1z8RpdfTid72DNSf/DEVo6VpOwkBtHbNwmlgBa40g3kO4kbi m0OazJeJGCdUsUvd3D5jm/xgdRHMwNvBlBDFXQTR9tJ/WgD7ZmyxsNWtYFtx7PZHYPOW+2qSgp36bMa9lQci8la6mXpVSNCrtOs= 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~public-inbox=simark.ca@sourceware.org Currently, nothing in the tree ever calls mdict_free. However, code does heap-allocate some multidicts. A simple way to see this is to use valgrind, run "gdb -readnow" on the executable created by gdb.dwarf2/struct-with-sig.exp, and then use "file" to clear the objfile list. This yields: ==1522843== 144 (16 direct, 128 indirect) bytes in 1 blocks are definitely lost in loss record 905 of 3,005 ==1522843== at 0x4843866: malloc (vg_replace_malloc.c:446) ==1522843== by 0x48E397: xmalloc (alloc.c:52) ==1522843== by 0x59DE66: multidictionary* xnew() (poison.h:102) ==1522843== by 0x59CFF4: mdict_create_hashed_expandable(language) (dictionary.c:965) ==1522843== by 0x50A269: buildsym_compunit::finish_block_internal(symbol*, pending**, pending_block*, dynamic_prop const*, unsigned long, unsigned long, int, int) (buildsym.c:221) ==1522843== by 0x50AE04: buildsym_compunit::end_compunit_symtab_get_static_block(unsigned long, int, int) (buildsym.c:818) ==1522843== by 0x50C4CF: buildsym_compunit::end_expandable_symtab(unsigned long) (buildsym.c:1037) ==1522843== by 0x61DBC6: process_full_type_unit (read.c:4970) This patch fixes the leaks by calling mdict_free when a blockvector is destroyed. --- gdb/block.c | 6 ++++++ gdb/block.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/gdb/block.c b/gdb/block.c index 02e6d0e4be2bab2c1b3750a2f396e4bc97b7bc5d..2d8d40ec4eb94a1c891a3f8b48972eff3050e66d 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -842,6 +842,12 @@ blockvector::append_block (struct block *block) m_blocks.push_back (block); } +blockvector::~blockvector () +{ + for (struct block *bl : m_blocks) + mdict_free (bl->multidict ()); +} + /* Implement 'maint info blocks' command. If passed an argument then print a list of all blocks at the given address. With no arguments then list all blocks at the current address of the current inferior. */ diff --git a/gdb/block.h b/gdb/block.h index 61070619ca7daa7b3310a9c5cd8d6ca86c044ada..98ce5a3839dbb8419c9e3a918d27b3b58485fea4 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -424,6 +424,8 @@ struct blockvector : m_blocks (nblocks, nullptr) {} + ~blockvector (); + /* Return a view on the blocks of this blockvector. */ gdb::array_view blocks () { -- 2.49.0