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]

[committed] fix trivial memory leak

There's a small leak in class optrecord_json_writer, which shows
up as a new leak in "make selftest-valgrind" as:

==50133== 40 bytes in 1 blocks are definitely lost in loss record 27 of 672
==50133==    at 0x4A0645D: malloc (in /usr/lib64/valgrind/
==50133==    by 0x1EF5CAF: xrealloc (xmalloc.c:177)
==50133==    by 0xEDDA56: void va_heap::reserve<json::array*>(vec<json::array*, va_heap, vl_embed>*&, unsigned int, bool) (vec.h:288)
==50133==    by 0xEDD74D: vec<json::array*, va_heap, vl_ptr>::reserve(unsigned int, bool) (vec.h:1621)
==50133==    by 0xEDD515: vec<json::array*, va_heap, vl_ptr>::safe_push(json::array* const&) (vec.h:1730)
==50133==    by 0xEDB060: optrecord_json_writer::optrecord_json_writer() (
==50133==    by 0xEDD141: selftest::test_building_json_from_dump_calls() (
==50133==    by 0xEDD3AF: selftest::optinfo_emit_json_cc_tests() (
==50133==    by 0x1DEB3AA: selftest::run_tests() (selftest-run-tests.c:78)
==50133==    by 0x1065264: toplev::run_self_tests() (toplev.c:2225)
==50133==    by 0x1065486: toplev::main(int, char**) (toplev.c:2303)
==50133==    by 0x1E4A092: main (main.c:39)

The fix is trivial.

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu;
manually checked "make selftest-valgrind" (which with this fix is now
back from four leaks down to three).

Committed to trunk as r262967 (under the "obvious" rule).

	* (class optrecord_json_writer): Convert
	field "m_scopes" from vec to auto_vec.
 gcc/ | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/ b/gcc/
index 6460a81..2199d52 100644
--- a/gcc/
+++ b/gcc/
@@ -75,7 +75,7 @@ private:
   json::array *m_root_tuple;
   /* The currently open scopes, for expressing nested optimization records.  */
-  vec<json::array *> m_scopes;
+  auto_vec<json::array *> m_scopes;
 /* optrecord_json_writer's ctor.  Populate the top-level parts of the

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