From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1552 invoked by alias); 12 Jun 2007 14:53:47 -0000 Received: (qmail 1495 invoked by uid 22791); 12 Jun 2007 14:53:47 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 12 Jun 2007 14:53:43 +0000 Received: from Relay1.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id F130E2162A for ; Tue, 12 Jun 2007 16:53:40 +0200 (CEST) From: Andreas Schwab To: gdb-patches@sourceware.org Subject: Re: Fix memory leaks in libunwind unwinder, part 2 References: <20070612142319.GH7815@caradoc.them.org> X-Yow: I put aside my copy of ``BOWLING WORLD'' and think about GUN CONTROL legislation.. Date: Tue, 12 Jun 2007 14:53:00 -0000 In-Reply-To: <20070612142319.GH7815@caradoc.them.org> (Daniel Jacobowitz's message of "Tue\, 12 Jun 2007 10\:23\:19 -0400") Message-ID: User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.97 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-06/txt/msg00174.txt.bz2 Daniel Jacobowitz writes: > On Fri, Jun 08, 2007 at 05:09:41PM +0200, Andreas Schwab wrote: >> This is the second part of the memory leak fix for the libunwind >> unwinder. There is no significant increase in gdb's memory any more. >> >> Andreas. >> >> 2007-06-08 Andreas Schwab >> >> * frame-unwind.h (frame_dealloc_cache_ftype): Define. >> (struct frame_unwind): Add dealloc_cache. >> * frame.c (reinit_frame_cache): Call dealloc_cache on all caches. >> >> * libunwind-frame.h (libunwind_frame_dealloc_cache): Declare. >> * libunwind-frame.c (libunwind_frame_dealloc_cache): Define. >> (libunwind_frame_unwind): Set dealloc_cache. >> * ia64-tdep.c (ia64_libunwind_frame_unwind): Set dealloc_cache. > > Thanks, this is OK with one fix. >> + /* Tear down all frame caches. */ >> + for (fi = current_frame; fi != NULL; fi = fi->prev) >> + { >> + if (fi->prologue_cache && fi->unwind->dealloc_cache) >> + fi->unwind->dealloc_cache (fi, fi->prologue_cache); >> + if (fi->base_cache && fi->base->unwind->dealloc_cache) >> + fi->base->unwind->dealloc_cache (fi, fi->base_cache); >> + } > > Compare with: > > /* Sneaky: If the low-level unwind and high-level base code share a > common unwinder, let them share the prologue cache. */ > if (fi->base->unwind == fi->unwind) > return fi->base->this_base (fi->next, &fi->prologue_cache); > return fi->base->this_base (fi->next, &fi->base_cache); > > I think you shouldn't dealloc the base cache if the two unwinders are > the same, right? In this case the base cache was never used, so there is nothing to deallocate. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."