From patchwork Mon Jan 19 15:04:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 4730 Received: (qmail 13379 invoked by alias); 19 Jan 2015 15:04:14 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 13355 invoked by uid 89); 19 Jan 2015 15:04:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 19 Jan 2015 15:04:12 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 8233A116343; Mon, 19 Jan 2015 10:04:10 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id oAKlcLm94KjH; Mon, 19 Jan 2015 10:04:10 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 52BCF11633A; Mon, 19 Jan 2015 10:04:10 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 225AA48E89; Mon, 19 Jan 2015 16:04:09 +0100 (CET) Date: Mon, 19 Jan 2015 16:04:09 +0100 From: Joel Brobecker To: Doug Evans Cc: "gdb-patches@sourceware.org" Subject: Re: ada symbol lookup cache: disable for 7.9? Message-ID: <20150119150409.GE4041@adacore.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) > It turns out that ada-lang.c accidently never uses its symbol lookup > cache (AFAICT!). > Rather, it will create a new one for each lookup, not recording the > cache in pspace_data, > and leaking the memory. Indeed! Attached is a patch that fixes this issue. I've tested on x86_64-linux, after having applied your testscase update (https://www.sourceware.org/ml/gdb-patches/2015-01/msg00510.html), as well as the fix you posted in PR 17855 (https://sourceware.org/bugzilla/show_bug.cgi?id=17855). No regression. As to whether we should deactivate it entirely for 7.9, I would personally prefer we tried to fix the bug(s), and see where we get. It used to work fine until I accidently botched the initialization of that cache when I tried to make it per-program-space. That's what I'll do anyway for AdaCore's version. However, if you think it's better to disable it entirely for the FSF version, I will accept that. gdb/ChangeLog: PR gdb/17854: * ada-lang.c (ada_get_symbol_cache): Set pspace_data->sym_cache when allocating a new one. We need your fix from PR 17855 before we can commit this one, because your testcase update reveals a regression as soon as the cache gets activated (I tested your patch on x86_64-linux as part of this testing). I'll start looking at re-caching entries obtained from cache. It seems that it's a real waste of memory, but not bad enough to actually cause a functional issue? Thanks, From 13e46b9a4e665ccc9ae6d99f63e240f98f67d184 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Mon, 19 Jan 2015 12:57:44 +0100 Subject: [PATCH] [Ada] pspace_data->sym_cache is always NULL The Ada symbol cache has been designed to have one instance of that of that cache per program space, and for each instance to be created on-demand. ada_get_symbol_cache is the function responsible for both lookup and creation on demand. Unfortunately, ada_get_symbol_cache forgot to store the reference to newly created caches, thus causing it to: - Leak old caches; - Allocate a new cache each time the cache is being searched or a new entry is to be inserted. This patch fixes the issue by avoiding the use of the local variable, which indirectly allowed the bug to happen. We manipulate the reference in the program-space data instead. gdb/ChangeLog: PR gdb/17854: * ada-lang.c (ada_get_symbol_cache): Set pspace_data->sym_cache when allocating a new one. --- gdb/ada-lang.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index f5753f1..2c98191 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -4404,15 +4404,14 @@ static struct ada_symbol_cache * ada_get_symbol_cache (struct program_space *pspace) { struct ada_pspace_data *pspace_data = get_ada_pspace_data (pspace); - struct ada_symbol_cache *sym_cache = pspace_data->sym_cache; - if (sym_cache == NULL) + if (pspace_data->sym_cache == NULL) { - sym_cache = XCNEW (struct ada_symbol_cache); - ada_init_symbol_cache (sym_cache); + pspace_data->sym_cache = XCNEW (struct ada_symbol_cache); + ada_init_symbol_cache (pspace_data->sym_cache); } - return sym_cache; + return pspace_data->sym_cache; } /* Clear all entries from the symbol cache. */ -- 1.9.1