This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
coverage.c: Fix leak of da_file_name
- From: David Malcolm <dmalcolm at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 09 Oct 2013 20:18:22 -0400
- Subject: coverage.c: Fix leak of da_file_name
- Authentication-results: sourceware.org; auth=none
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:
http://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=963eb9c93e3e599ff577f9c3a19c6ccdcc9779c5
)
commit 88e2ca9c4f0e031bd1479840e4e1739ca4457ab3
Author: David Malcolm <dmalcolm@redhat.com>
Date: Wed Oct 9 13:47:13 2013 -0400
Fix leak of coverage.c:da_file_name
gcc/
* 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"