This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

coverage.c: Fix leak of da_file_name

coverage_init allocates da_file_name using XNEWVEC, but it is never
freed.  This shows up as a slow memory leak in my JIT code when
repeatedly invoking the compiler code within a single process.

This patch frees it in coverage_finish with XDELETEVEC (and NULLs it to
be sure).

Bootstrapped and regtested against trunk on x86_64-unknown-linux.

OK for trunk?

(Seen using valgrind; I've already committed this on my dmalcolm/jit
branch as:;a=commitdiff;h=963eb9c93e3e599ff577f9c3a19c6ccdcc9779c5

commit 88e2ca9c4f0e031bd1479840e4e1739ca4457ab3
Author: David Malcolm <>
Date:   Wed Oct 9 13:47:13 2013 -0400

    Fix leak of coverage.c:da_file_name
    	* coverage.c (coverage_finish): Fix leak of da_file_name.

diff --git a/gcc/coverage.c b/gcc/coverage.c
index 9bc23c4..3c36c6f 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -1209,6 +1209,9 @@ coverage_finish (void)
 	fn_ctor = coverage_obj_fn (fn_ctor, fn->fn_decl, fn);
       coverage_obj_finish (fn_ctor);
+  XDELETEVEC (da_file_name);
+  da_file_name = NULL;
 #include "gt-coverage.h"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]