[Patch] Fortran: Avoid double-free with parse error (PR96041, PR93423)

Andre Vehreschild vehre@gmx.de
Thu Sep 17 11:45:26 GMT 2020


Hi Tobias,

I see. Then OK for trunk by me.

- Andre

On Wed, 16 Sep 2020 10:35:53 +0200
Tobias Burnus <tobias@codesourcery.com> wrote:

> Hi Andre,
> 
> On 9/16/20 9:58 AM, Andre Vehreschild wrote:
> > +      st->n.sym = NULL;
> >
> > Don't we need free or unlink the st node from the symtree, too?  
> 
> I did not see a way to simply remove a single symtree; as this
> is the error case, I left the item in the symtree.
> 
> The symtree itself is removed when the 'contains' is
> processed by calling:
>    gfc_free_namespace (...)
> which calls
>    free_sym_tree (ns->sym_root)
> and that function is:
>    if (sym_tree == NULL)
>      return;
>    free_sym_tree (sym_tree->left);
>    free_sym_tree (sym_tree->right);
>    gfc_release_symbol (sym_tree->n.sym);
>    free (sym_tree);
> 
> This "gfc_release_symbol" was actually the call which
> handled our "bp" symbol – deleting n.sym->formal.
> 
> The parent namespace was still present and called
> resolve_formal – which den caused the ICE as its
> n.sym->formal was before deleted in "our" namespace.
> 
> Tobias
> 
> -----------------
> Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
> Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung,
> Alexander Walter


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 


More information about the Gcc-patches mailing list