Patchwork Fix accesses to freed up memory in var-tracking (PR debug/53706)

login
register
mail settings
Submitter Jakub Jelinek
Date June 21, 2012, 6:15 a.m.
Message ID <20120621061538.GO20264@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/166230/
State New
Headers show

Comments

Jakub Jelinek - June 21, 2012, 6:15 a.m.
Hi!

During htab_delete (dropped_values), loc_exp_dep_pool
allocated objects might be accessed, so it is better to free the
pool afterwards.

Bootstrapped/regtested on i686-linux, ok for trunk?

2012-06-21  Jakub Jelinek  <jakub@redhat.com>

	PR debug/53706
	* var-tracking.c (vt_emit_notes): Free loc_exp_dep_pool
	only after htab_delete call.


	Jakub
Richard Guenther - June 21, 2012, 9:22 a.m.
On Thu, Jun 21, 2012 at 8:15 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> During htab_delete (dropped_values), loc_exp_dep_pool
> allocated objects might be accessed, so it is better to free the
> pool afterwards.
>
> Bootstrapped/regtested on i686-linux, ok for trunk?

Looks obvious.

Thanks,
Richard.

> 2012-06-21  Jakub Jelinek  <jakub@redhat.com>
>
>        PR debug/53706
>        * var-tracking.c (vt_emit_notes): Free loc_exp_dep_pool
>        only after htab_delete call.
>
> --- gcc/var-tracking.c.jj       2012-06-14 20:26:02.000000000 +0200
> +++ gcc/var-tracking.c  2012-06-18 09:02:56.142742617 +0200
> @@ -9127,9 +9127,9 @@ vt_emit_notes (void)
>
>   if (MAY_HAVE_DEBUG_INSNS)
>     {
> +      htab_delete (dropped_values);
>       free_alloc_pool (loc_exp_dep_pool);
>       loc_exp_dep_pool = NULL;
> -      htab_delete (dropped_values);
>     }
>
>   emit_notes = false;
>
>        Jakub

Patch

--- gcc/var-tracking.c.jj	2012-06-14 20:26:02.000000000 +0200
+++ gcc/var-tracking.c	2012-06-18 09:02:56.142742617 +0200
@@ -9127,9 +9127,9 @@  vt_emit_notes (void)
 
   if (MAY_HAVE_DEBUG_INSNS)
     {
+      htab_delete (dropped_values);
       free_alloc_pool (loc_exp_dep_pool);
       loc_exp_dep_pool = NULL;
-      htab_delete (dropped_values);
     }
 
   emit_notes = false;