* [committed] optinfo-emit-json.cc: fix trivial memory leak
@ 2018-07-25 14:22 David Malcolm
0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2018-07-25 14:22 UTC (permalink / raw)
To: gcc-patches; +Cc: David Malcolm
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/vgpreload_memcheck-amd64-linux.so)
==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() (optinfo-emit-json.cc:124)
==50133== by 0xEDD141: selftest::test_building_json_from_dump_calls() (optinfo-emit-json.cc:935)
==50133== by 0xEDD3AF: selftest::optinfo_emit_json_cc_tests() (optinfo-emit-json.cc:955)
==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).
gcc/ChangeLog:
* optinfo-emit-json.cc (class optrecord_json_writer): Convert
field "m_scopes" from vec to auto_vec.
---
gcc/optinfo-emit-json.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/optinfo-emit-json.cc b/gcc/optinfo-emit-json.cc
index 6460a81..2199d52 100644
--- a/gcc/optinfo-emit-json.cc
+++ b/gcc/optinfo-emit-json.cc
@@ -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
--
1.8.5.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-07-25 14:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-25 14:22 [committed] optinfo-emit-json.cc: fix trivial memory leak David Malcolm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).