This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: memory leak(?) in stack command
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Sat, 14 Dec 2013 12:55:48 +0100
- Subject: Re: memory leak(?) in stack command
On Sat, 2013-12-14 at 13:34 +0900, Masatake YAMATO wrote:
> I've tried stack command under valgrind.
> valgrind reports some memory leaks. Is it expected behavior or known issue?
Thanks for the report. That is certainly not expected. stack shouldn't
leak memory. I think the leaks can be solved as follows:
diff --git a/libdwfl/dwfl_module.c b/libdwfl/dwfl_module.c
index f914b3a..bb167ab 100644
--- a/libdwfl/dwfl_module.c
+++ b/libdwfl/dwfl_module.c
@@ -84,6 +84,12 @@ __libdwfl_module_free (Dwfl_Module *mod)
if (mod->build_id_bits != NULL)
free (mod->build_id_bits);
+ if (mod->reloc_info != NULL)
+ free (mod->reloc_info);
+
+ if (mod->eh_cfi != NULL)
+ dwarf_cfi_end (mod->eh_cfi);
+
free (mod->name);
free (mod);
}
diff --git a/libdwfl/frame_unwind.c b/libdwfl/frame_unwind.c
index 1aed8cb..ad3a776 100644
--- a/libdwfl/frame_unwind.c
+++ b/libdwfl/frame_unwind.c
@@ -576,6 +576,7 @@ handle_cfi (Dwfl_Frame *state, Dwarf_Addr pc, Dwarf_CFI *cfi, Dwarf_Addr bias)
else
unwound->pc_state = DWFL_FRAME_STATE_PC_SET;
}
+ free (frame);
}
void
Does the above work for you?
I'll test some more to make sure that is really correct.
Thanks,
Mark