diff mbox

[06/21] PR jit/63854: Fix leak of opts_obstack

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

Commit Message

David Malcolm Nov. 19, 2014, 10:46 a.m. UTC
This was leaking about 4KB per iteration:

16,256 bytes in 4 blocks are definitely lost in loss record 233 of 239
   at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x5D75C17: xmalloc (xmalloc.c:147)
   by 0x30958842DB: _obstack_begin (obstack.c:184)
   by 0x5D1D317: init_options_struct(gcc_options*, gcc_options*) (opts.c:279)
   by 0x532DB0C: toplev::main(int, char**) (toplev.c:2081)
   by 0x4DE766F: gcc::jit::playback::context::compile() (jit-playback.c:1615)
   by 0x4DD76DA: gcc::jit::recording::context::compile() (jit-recording.c:861)
   by 0x4DD5BD2: gcc_jit_context_compile (libgccjit.c:2014)
   by 0x401CA4: test_jit (harness.h:190)
   by 0x401D88: main (harness.h:232)

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

Comments

Richard Biener Nov. 19, 2014, 11:43 a.m. UTC | #1
On Wed, Nov 19, 2014 at 11:46 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> This was leaking about 4KB per iteration:

Ok.

Thanks,
Richard.

> 16,256 bytes in 4 blocks are definitely lost in loss record 233 of 239
>    at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
>    by 0x5D75C17: xmalloc (xmalloc.c:147)
>    by 0x30958842DB: _obstack_begin (obstack.c:184)
>    by 0x5D1D317: init_options_struct(gcc_options*, gcc_options*) (opts.c:279)
>    by 0x532DB0C: toplev::main(int, char**) (toplev.c:2081)
>    by 0x4DE766F: gcc::jit::playback::context::compile() (jit-playback.c:1615)
>    by 0x4DD76DA: gcc::jit::recording::context::compile() (jit-recording.c:861)
>    by 0x4DD5BD2: gcc_jit_context_compile (libgccjit.c:2014)
>    by 0x401CA4: test_jit (harness.h:190)
>    by 0x401D88: main (harness.h:232)
>
> gcc/ChangeLog:
>         PR jit/63854
>         * toplev.c (toplev::finalize): Free opts_obstack.
> ---
>  gcc/toplev.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/gcc/toplev.c b/gcc/toplev.c
> index 291b84d..0d617c2 100644
> --- a/gcc/toplev.c
> +++ b/gcc/toplev.c
> @@ -2178,4 +2178,6 @@ toplev::finalize (void)
>    /* Clean up the context (and pass_manager etc). */
>    delete g;
>    g = NULL;
> +
> +  obstack_free (&opts_obstack, NULL);
>  }
> --
> 1.8.5.3
>
diff mbox

Patch

diff --git a/gcc/toplev.c b/gcc/toplev.c
index 291b84d..0d617c2 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2178,4 +2178,6 @@  toplev::finalize (void)
   /* Clean up the context (and pass_manager etc). */
   delete g;
   g = NULL;
+
+  obstack_free (&opts_obstack, NULL);
 }