This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 02/21] PR jit/63854: Fix memory leak of reginfo.c: valid_mode_changes_obstack
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: David Malcolm <dmalcolm at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, jit at gcc dot gnu dot org
- Date: Wed, 19 Nov 2014 12:11:28 +0100
- Subject: Re: [PATCH 02/21] PR jit/63854: Fix memory leak of reginfo.c: valid_mode_changes_obstack
- Authentication-results: sourceware.org; auth=none
- References: <1416393981-39626-1-git-send-email-dmalcolm at redhat dot com> <1416393981-39626-3-git-send-email-dmalcolm at redhat dot com>
On Wed, Nov 19, 2014 at 11:46 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> Valgrind shows this fixes ~4 KB of leak per iteration (on x86_64) by
> plugging this leak allocated at reginfo.c:1327:
> gcc_obstack_init (&valid_mode_changes_obstack);
Ok.
Thanks,
Richard.
> ==57820== 16,256 bytes in 4 blocks are definitely lost in loss record 906 of 917
> ==57820== at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==57820== by 0x59A6747: xmalloc (xmalloc.c:147)
> ==57820== by 0x30958842DB: _obstack_begin (obstack.c:184)
> ==57820== by 0x51C1EC1: init_subregs_of_mode() (reginfo.c:1327)
> ==57820== by 0x50D2A38: init_costs() (ira-costs.c:2181)
> ==57820== by 0x50D74A8: ira_costs() (ira-costs.c:2211)
> ==57820== by 0x50D1326: ira_build() (ira-build.c:3459)
> ==57820== by 0x50C909C: (anonymous namespace)::pass_ira::execute(function*) (ira.c:5227)
> ==57820== by 0x51884F7: execute_one_pass(opt_pass*) (passes.c:2269)
> ==57820== by 0x5188B75: execute_pass_list_1(opt_pass*) (passes.c:2321)
> ==57820== by 0x5188B87: execute_pass_list_1(opt_pass*) (passes.c:2322)
> ==57820== by 0x5188BC8: execute_pass_list(function*, opt_pass*) (passes.c:2332)
>
> gcc/ChangeLog:
> PR jit/63854
> * reginfo.c (finish_subregs_of_mode): Replace obstack_finish with
> obstack_free when cleaning up valid_mode_changes_obstack.
> ---
> gcc/reginfo.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/reginfo.c b/gcc/reginfo.c
> index efe23cd..c2daf22 100644
> --- a/gcc/reginfo.c
> +++ b/gcc/reginfo.c
> @@ -1343,7 +1343,7 @@ void
> finish_subregs_of_mode (void)
> {
> XDELETEVEC (valid_mode_changes);
> - obstack_finish (&valid_mode_changes_obstack);
> + obstack_free (&valid_mode_changes_obstack, NULL);
> }
>
> /* Free all data attached to the structure. This isn't a destructor because
> --
> 1.8.5.3
>