From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104086 invoked by alias); 25 Jul 2018 14:22:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 104073 invoked by uid 89); 25 Jul 2018 14:22:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=mainc, toplev, char**, UD:main.c X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Jul 2018 14:22:39 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D00D3001FA0 for ; Wed, 25 Jul 2018 14:22:38 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-35.phx2.redhat.com [10.3.112.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8045F5D9CD; Wed, 25 Jul 2018 14:22:37 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [committed] optinfo-emit-json.cc: fix trivial memory leak Date: Wed, 25 Jul 2018 14:22:00 -0000 Message-Id: <1532531248-25116-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg01542.txt.bz2 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(vec*&, unsigned int, bool) (vec.h:288) ==50133== by 0xEDD74D: vec::reserve(unsigned int, bool) (vec.h:1621) ==50133== by 0xEDD515: vec::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 m_scopes; + auto_vec m_scopes; }; /* optrecord_json_writer's ctor. Populate the top-level parts of the -- 1.8.5.3