From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19005 invoked by alias); 26 Nov 2014 09:59:27 -0000 Mailing-List: contact jit-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: jit-owner@gcc.gnu.org Received: (qmail 18973 invoked by uid 89); 26 Nov 2014 09:59:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.98.4 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-oi0-f47.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=X6YtbZlE6zvChRdJmMBNIVYlRbaTRhGZ3z8G7Y7Ftsw=; b=wvIa40L1Y309EmaWRC0IZ5+fdYuGS59EQqjZrNGBSYKU4t1KwpyskPB/mqYr7BD7aW aJJ8/P+9Z6rG+vTuHiExR2HFuoxPNxP1SDqYzF8yuQQ4AGHj7pbB+ulO9kbKAp1t+5cG z3FDg2K16iWrF/6WHdIzjaIleVgpphE9d6VtAsITXHq8vL/xDfaKie8kKUw+GXDDkYwS X5WPEzqXOlSAIweoJG5aFKfyYUI+GoH73WmkTxZqBsRq0R0UbybyrxDIeVjBeNEbsNix +foxouswdYoKHiC2OcyJMEzFfIwM9s2xxX3n7P64UHLgXoaAwh00NKNvsPKCufX4nAE4 +b3A== MIME-Version: 1.0 X-Received: by 10.182.130.162 with SMTP id of2mr18592834obb.52.1416995962257; Wed, 26 Nov 2014 01:59:22 -0800 (PST) In-Reply-To: <1416965978-15582-2-git-send-email-dmalcolm@redhat.com> References: <1416965978-15582-1-git-send-email-dmalcolm@redhat.com> <1416965978-15582-2-git-send-email-dmalcolm@redhat.com> Date: Wed, 01 Jan 2014 00:00:00 -0000 Message-ID: Subject: Re: [PATCH 01/08] PR jit/63854: Fix leak in tree-ssa-math-opts.c From: Richard Biener To: David Malcolm Cc: GCC Patches , jit@gcc.gnu.org Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2014-q4/txt/msg00225.txt.bz2 On Wed, Nov 26, 2014 at 2:39 AM, David Malcolm wrote: > Running testsuite/jit.dg/test-functions.c under valgrind showed this > leak (amongst others): > > 400 bytes in 10 blocks are definitely lost in loss record 142 of 181 > at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) > by 0x5DCDF2F: xrealloc (xmalloc.c:177) > by 0x53726CE: void va_heap::reserve(vec*&, unsigned int, bool) (vec.h:310) > by 0x5371BB1: vec::reserve(unsigned int, bool) (vec.h:1428) > by 0x5370F5D: vec::safe_push(gimple_statement_base* const&) (vec.h:1537) > by 0x5523E71: maybe_record_sincos(vec*, basic_block_def**, gimple_statement_base*) (tree-ssa-math-opts.c:718) > by 0x552403E: execute_cse_sincos_1(tree_node*) (tree-ssa-math-opts.c:760) > by 0x5526224: (anonymous namespace)::pass_cse_sincos::execute(function*) (tree-ssa-math-opts.c:1497) > by 0x5250095: execute_one_pass(opt_pass*) (passes.c:2311) > by 0x525030C: execute_pass_list_1(opt_pass*) (passes.c:2363) > by 0x525033D: execute_pass_list_1(opt_pass*) (passes.c:2364) > by 0x525037A: execute_pass_list(function*, opt_pass*) (passes.c:2374) > > For some reason (which I've filed for myself as PR jit/64020), this > code was bailing out: > > fndecl = mathfn_built_in (type, BUILT_IN_CEXPI); > if (!fndecl) > return false; > > That exit path is missing a: > stmts.release (); > and thus is leaking the buffer of stmts on the way out. > > Fix it by converting stmts from vec<> to auto_vec<>, to avoid the need to > have handwritten release calls on every exit path. Ok. Thanks, Richard. > gcc/ChangeLog: > PR jit/63854 > * tree-ssa-math-opts.c (execute_cse_sincos_1): Fix a missing > release of stmts by converting it to an auto_vec. > --- > gcc/tree-ssa-math-opts.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c > index f9c30bf..5e08c7ee 100644 > --- a/gcc/tree-ssa-math-opts.c > +++ b/gcc/tree-ssa-math-opts.c > @@ -740,7 +740,7 @@ execute_cse_sincos_1 (tree name) > tree fndecl, res, type; > gimple def_stmt, use_stmt, stmt; > int seen_cos = 0, seen_sin = 0, seen_cexpi = 0; > - vec stmts = vNULL; > + auto_vec stmts; > basic_block top_bb = NULL; > int i; > bool cfg_changed = false; > @@ -773,10 +773,7 @@ execute_cse_sincos_1 (tree name) > } > > if (seen_cos + seen_sin + seen_cexpi <= 1) > - { > - stmts.release (); > - return false; > - } > + return false; > > /* Simply insert cexpi at the beginning of top_bb but not earlier than > the name def statement. */ > @@ -835,8 +832,6 @@ execute_cse_sincos_1 (tree name) > cfg_changed = true; > } > > - stmts.release (); > - > return cfg_changed; > } > > -- > 1.8.5.3 >