This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Fix memory leaks in libunwind unwinder, part 2
Daniel Jacobowitz <drow@false.org> 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 <schwab@suse.de>
>>
>> * 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."