diff mbox

[05/21] PR jit/63854: Fix memory leak of save_decoded_options

Message ID 1416393981-39626-6-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm Nov. 19, 2014, 10:46 a.m. UTC
This commit fixes this leak from opts-common.c, about 4KB per iteration.

==57820== 18,816 (2,560 direct, 16,256 indirect) bytes in 4 blocks are definitely lost in loss record 907 of 917
==57820==    at 0x4A083AA: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==57820==    by 0x59A67CC: xrealloc (xmalloc.c:179)
==57820==    by 0x59587C9: decode_cmdline_options_to_array(unsigned int, char const**, unsigned int, cl_decoded_option**, unsigned int*) (opts-common.c:885)
==57820==    by 0x4E2ED90: toplev::main(int, char**) (toplev.c:2089)
==57820==    by 0x4E43186: gcc::jit::playback::context::compile() (jit-playback.c:1615)
==57820==    by 0x4E4018D: gcc::jit::recording::context::compile() (jit-recording.c:861)
==57820==    by 0x401CA4: test_jit (harness.h:190)
==57820==    by 0x401D88: main (harness.h:232)

gcc/ChangeLog:
	PR jit/63854
	* toplev.c (toplev::finalize): Clean up save_decoded_options.
---
 gcc/toplev.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Richard Biener Nov. 19, 2014, 11:49 a.m. UTC | #1
On Wed, Nov 19, 2014 at 11:46 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> This commit fixes this leak from opts-common.c, about 4KB per iteration.

Ok.

Thanks,
Richard.

> ==57820== 18,816 (2,560 direct, 16,256 indirect) bytes in 4 blocks are definitely lost in loss record 907 of 917
> ==57820==    at 0x4A083AA: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==57820==    by 0x59A67CC: xrealloc (xmalloc.c:179)
> ==57820==    by 0x59587C9: decode_cmdline_options_to_array(unsigned int, char const**, unsigned int, cl_decoded_option**, unsigned int*) (opts-common.c:885)
> ==57820==    by 0x4E2ED90: toplev::main(int, char**) (toplev.c:2089)
> ==57820==    by 0x4E43186: gcc::jit::playback::context::compile() (jit-playback.c:1615)
> ==57820==    by 0x4E4018D: gcc::jit::recording::context::compile() (jit-recording.c:861)
> ==57820==    by 0x401CA4: test_jit (harness.h:190)
> ==57820==    by 0x401D88: main (harness.h:232)
>
> gcc/ChangeLog:
>         PR jit/63854
>         * toplev.c (toplev::finalize): Clean up save_decoded_options.
> ---
>  gcc/toplev.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/gcc/toplev.c b/gcc/toplev.c
> index 876279f..291b84d 100644
> --- a/gcc/toplev.c
> +++ b/gcc/toplev.c
> @@ -2173,6 +2173,8 @@ toplev::finalize (void)
>    finalize_options_struct (&global_options);
>    finalize_options_struct (&global_options_set);
>
> +  XDELETEVEC (save_decoded_options);
> +
>    /* Clean up the context (and pass_manager etc). */
>    delete g;
>    g = NULL;
> --
> 1.8.5.3
>
diff mbox

Patch

diff --git a/gcc/toplev.c b/gcc/toplev.c
index 876279f..291b84d 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2173,6 +2173,8 @@  toplev::finalize (void)
   finalize_options_struct (&global_options);
   finalize_options_struct (&global_options_set);
 
+  XDELETEVEC (save_decoded_options);
+
   /* Clean up the context (and pass_manager etc). */
   delete g;
   g = NULL;