diff mbox

Fix sel-sched memory leak (PR middle-end/56461)

Message ID 20130304212009.GY12913@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek March 4, 2013, 9:20 p.m. UTC
Hi!

alloc_succs_info creates vectors up to and including
succs_info_pool.max_top, so without the following fix we leak the
last set of 3 vectors.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2013-03-04  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/56461
	* sel-sched-ir.c (free_sched_pools): Release
	succs_info_pool.stack[succs_info_pool.max_top] vectors too
	if succs_info_pool.max_top isn't -1.


	Jakub

Comments

Andrey Belevantsev March 5, 2013, 5:55 a.m. UTC | #1
Hi Jakub,

On 2013-03-05 01:20, Jakub Jelinek wrote:
> Hi!
> 
> alloc_succs_info creates vectors up to and including
> succs_info_pool.max_top, so without the following fix we leak the
> last set of 3 vectors.
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, 
> ok for
> trunk?

This is fine, thanks a lot.  I can take care of backporting this to the 
older branches with the other sel-sched patches.

Andrey

> 
> 2013-03-04  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR middle-end/56461
> 	* sel-sched-ir.c (free_sched_pools): Release
> 	succs_info_pool.stack[succs_info_pool.max_top] vectors too
> 	if succs_info_pool.max_top isn't -1.
> 
> --- gcc/sel-sched-ir.c.jj	2013-02-27 14:59:51.000000000 +0100
> +++ gcc/sel-sched-ir.c	2013-03-04 17:47:34.705686637 +0100
> @@ -5020,7 +5020,7 @@ free_sched_pools (void)
> 
>    free_alloc_pool (sched_lists_pool);
>    gcc_assert (succs_info_pool.top == -1);
> -  for (i = 0; i < succs_info_pool.max_top; i++)
> +  for (i = 0; i <= succs_info_pool.max_top; i++)
>      {
>        succs_info_pool.stack[i].succs_ok.release ();
>        succs_info_pool.stack[i].succs_other.release ();
> 
> 	Jakub
diff mbox

Patch

--- gcc/sel-sched-ir.c.jj	2013-02-27 14:59:51.000000000 +0100
+++ gcc/sel-sched-ir.c	2013-03-04 17:47:34.705686637 +0100
@@ -5020,7 +5020,7 @@  free_sched_pools (void)
 
   free_alloc_pool (sched_lists_pool);
   gcc_assert (succs_info_pool.top == -1);
-  for (i = 0; i < succs_info_pool.max_top; i++)
+  for (i = 0; i <= succs_info_pool.max_top; i++)
     {
       succs_info_pool.stack[i].succs_ok.release ();
       succs_info_pool.stack[i].succs_other.release ();