* [PATCH] ctf-reader: Fix memory leak reported by valgrind
@ 2021-11-22 18:55 Guillermo E. Martinez
2021-11-22 20:11 ` Jose E. Marchesi
2021-11-29 7:48 ` Dodji Seketeli
0 siblings, 2 replies; 3+ messages in thread
From: Guillermo E. Martinez @ 2021-11-22 18:55 UTC (permalink / raw)
To: libabigail
Hello,
Running unit test with check-valgrind, CTF reader test fails.
I'll appreciate your comments .. :-)
Thanks in advanced!
Guillermo
runtestreadctf fails executed by make check-valgrind, a memory leak is
reported:
at 0x48397B5: malloc (vg_replace_malloc.c:381)
by 0x56E6316: ctf_bufopen_internal (ctf-open.c:1388)
by 0x56E5FD3: ctf_bufopen (ctf-open.c:1297)
by 0x56CD688: ctf_arc_bufopen (ctf-archive.c:444)
by 0x4EB31FD: abigail::ctf_reader::read_corpus(abigail::ctf_reader::read_context*,\
abigail::elf_reader::status&) (abg-ctf-reader.cc:1111)
by 0x10C6BB: test_task_ctf::perform() (test-read-ctf.cc:236)
by 0x4E8E9AF: abigail::workers::worker::wait_to_execute_a_task\
(abigail::workers::queue::priv*) (abg-workers.cc:400)
by 0x543BEAD: start_thread (pthread_create.c:463)
by 0x5369A5E: clone (clone.S:95)
This is happening because `ctf_variable_next' bumps the dictionary
reference counter, so when `ctf_close' is called it doesn't free the
memory allocated by the dict, because `ctf_refcnt' is greater than one.
Therefore `ctf_dict_close' is required.
* src/abg-ctf-reader.cc (process_ctf_archive): Add
ctf_dict_close
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
---
src/abg-ctf-reader.cc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc
index 3e17e049..b31a1b1f 100644
--- a/src/abg-ctf-reader.cc
+++ b/src/abg-ctf-reader.cc
@@ -941,6 +941,8 @@ process_ctf_archive(read_context *ctxt, corpus_sptr corp)
}
if (ctf_errno(ctf_dict) != ECTF_NEXT_END)
fprintf(stderr, "ERROR from ctf_symbol_next\n");
+
+ ctf_dict_close(ctf_dict);
}
if (ctf_err != ECTF_NEXT_END)
fprintf(stderr, "ERROR from ctf_archive_next\n");
--
2.33.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ctf-reader: Fix memory leak reported by valgrind
2021-11-22 18:55 [PATCH] ctf-reader: Fix memory leak reported by valgrind Guillermo E. Martinez
@ 2021-11-22 20:11 ` Jose E. Marchesi
2021-11-29 7:48 ` Dodji Seketeli
1 sibling, 0 replies; 3+ messages in thread
From: Jose E. Marchesi @ 2021-11-22 20:11 UTC (permalink / raw)
To: Guillermo E. Martinez via Libabigail
> Hello,
>
> Running unit test with check-valgrind, CTF reader test fails.
>
> I'll appreciate your comments .. :-)
>
> Thanks in advanced!
> Guillermo
LGTM.
>
> runtestreadctf fails executed by make check-valgrind, a memory leak is
> reported:
>
> at 0x48397B5: malloc (vg_replace_malloc.c:381)
> by 0x56E6316: ctf_bufopen_internal (ctf-open.c:1388)
> by 0x56E5FD3: ctf_bufopen (ctf-open.c:1297)
> by 0x56CD688: ctf_arc_bufopen (ctf-archive.c:444)
> by 0x4EB31FD: abigail::ctf_reader::read_corpus(abigail::ctf_reader::read_context*,\
> abigail::elf_reader::status&) (abg-ctf-reader.cc:1111)
> by 0x10C6BB: test_task_ctf::perform() (test-read-ctf.cc:236)
> by 0x4E8E9AF: abigail::workers::worker::wait_to_execute_a_task\
> (abigail::workers::queue::priv*) (abg-workers.cc:400)
> by 0x543BEAD: start_thread (pthread_create.c:463)
> by 0x5369A5E: clone (clone.S:95)
>
> This is happening because `ctf_variable_next' bumps the dictionary
> reference counter, so when `ctf_close' is called it doesn't free the
> memory allocated by the dict, because `ctf_refcnt' is greater than one.
> Therefore `ctf_dict_close' is required.
>
> * src/abg-ctf-reader.cc (process_ctf_archive): Add
> ctf_dict_close
>
> Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
> ---
> src/abg-ctf-reader.cc | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc
> index 3e17e049..b31a1b1f 100644
> --- a/src/abg-ctf-reader.cc
> +++ b/src/abg-ctf-reader.cc
> @@ -941,6 +941,8 @@ process_ctf_archive(read_context *ctxt, corpus_sptr corp)
> }
> if (ctf_errno(ctf_dict) != ECTF_NEXT_END)
> fprintf(stderr, "ERROR from ctf_symbol_next\n");
> +
> + ctf_dict_close(ctf_dict);
> }
> if (ctf_err != ECTF_NEXT_END)
> fprintf(stderr, "ERROR from ctf_archive_next\n");
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ctf-reader: Fix memory leak reported by valgrind
2021-11-22 18:55 [PATCH] ctf-reader: Fix memory leak reported by valgrind Guillermo E. Martinez
2021-11-22 20:11 ` Jose E. Marchesi
@ 2021-11-29 7:48 ` Dodji Seketeli
1 sibling, 0 replies; 3+ messages in thread
From: Dodji Seketeli @ 2021-11-29 7:48 UTC (permalink / raw)
To: Guillermo E. Martinez via Libabigail
Hello,
"Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> a écrit:
[...]
>
> * src/abg-ctf-reader.cc (process_ctf_archive): Add
> ctf_dict_close
>
> Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
[...]
"Jose E. Marchesi via Libabigail" <libabigail@sourceware.org> a écrit:
[...]
> LGTM.
Applied to master, thanks!
[...]
Cheers,
--
Dodji
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-29 7:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22 18:55 [PATCH] ctf-reader: Fix memory leak reported by valgrind Guillermo E. Martinez
2021-11-22 20:11 ` Jose E. Marchesi
2021-11-29 7:48 ` Dodji Seketeli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).