This is the mail archive of the gcc-patches@gcc.gnu.org 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]

[PATCH] Fix memory leak in tree-if-conv.c


On 05/03/2016 11:07 AM, Bin.Cheng wrote:
> Patch applied as suggested at r235808.
> 
> Thanks,
> bin

Hi.

Following patch introduces memory leak:
/home/marxin/Programming/gcc2/objdir/gcc/xgcc -B/home/marxin/Programming/gcc2/objdir/gcc/    -fno-diagnostics-show-caret -fdiagnostics-color=never    -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  -w -c -o 920928-2.o /home/marxin/Programming/gcc2/gcc/testsuite/gcc.c-torture/compile/920928-2.c

==5714== 40 bytes in 1 blocks are definitely lost in loss record 38 of 905

==5714==    at 0x4C2A00F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)

==5714==    by 0x109C76F: xrealloc (xmalloc.c:178)

==5714==    by 0xA89696: reserve<edge_def*> (vec.h:288)

==5714==    by 0xA89696: reserve (vec.h:1438)

==5714==    by 0xA89696: safe_push (vec.h:1547)

==5714==    by 0xA89696: ifcvt_split_critical_edges (tree-if-conv.c:2397)

==5714==    by 0xA89696: tree_if_conversion (tree-if-conv.c:2725)

==5714==    by 0xA89696: (anonymous namespace)::pass_if_conversion::execute(function*) (tree-if-conv.c:2832)

==5714==    by 0x98A9D3: execute_one_pass(opt_pass*) (passes.c:2348)

==5714==    by 0x98AF17: execute_pass_list_1(opt_pass*) [clone .constprop.84] (passes.c:2432)

==5714==    by 0x98AF29: execute_pass_list_1(opt_pass*) [clone .constprop.84] (passes.c:2433)

==5714==    by 0x98AF29: execute_pass_list_1(opt_pass*) [clone .constprop.84] (passes.c:2433)

==5714==    by 0x98AF74: execute_pass_list(function*, opt_pass*) (passes.c:2443)

==5714==    by 0x72DEB2: cgraph_node::expand() (cgraphunit.c:1982)

==5714==    by 0x72F3A3: expand_all_functions (cgraphunit.c:2118)

==5714==    by 0x72F3A3: symbol_table::compile() [clone .part.49] (cgraphunit.c:2474)

==5714==    by 0x730D47: compile (cgraphunit.c:2538)

==5714==    by 0x730D47: symbol_table::finalize_compilation_unit() (cgraphunit.c:2564)

==5714==    by 0xA392B7: compile_file() (toplev.c:488)

==5714==    by 0x616117: do_compile (toplev.c:1987)

==5714==    by 0x616117: toplev::main(int, char**) (toplev.c:2095)

==5714==    by 0x6182B6: main (main.c:39)


Following patch fixes that, ready after it bootstraps and survives regtests?

Thanks,
Martin
>From 6ea5e00ce55e8e22fe9429f0cbd942f4938643a6 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Fri, 6 May 2016 14:20:28 +0200
Subject: [PATCH] Fix memory leak in tree-if-conv.c

gcc/ChangeLog:

2016-05-06  Martin Liska  <mliska@suse.cz>

	* tree-if-conv.c (ifcvt_split_critical_edges): Use auto_vec
	instead of vec as the vector is local to the function.
---
 gcc/tree-if-conv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 3d7c613..3ad8e87 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -2361,7 +2361,7 @@ ifcvt_split_critical_edges (struct loop *loop, bool aggressive_if_conv)
   gimple *stmt;
   edge e;
   edge_iterator ei;
-  vec<edge> critical_edges = vNULL;
+  auto_vec<edge> critical_edges;
 
   /* Loop is not well formed.  */
   if (num <= 2 || loop->inner || !single_exit (loop))
@@ -2381,7 +2381,6 @@ ifcvt_split_critical_edges (struct loop *loop, bool aggressive_if_conv)
 		     bb->index, MAX_PHI_ARG_NUM);
 
 	  free (body);
-	  critical_edges.release ();
 	  return false;
 	}
       if (bb == loop->latch || bb_with_exit_edge_p (loop, bb))
-- 
2.8.1


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