https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106050

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #5 from Mikael Morin <mikael at gcc dot gnu.org> ---
When matching statement "type t(k)", two symbols are created, one for t and one
for k.
t is in gfc_current_ns and k is in t's f2k_derived namespace.
If the statement is rejected, both t and k need to be freed.
But one should care about ordering, as the release of t frees f2k_derived,
which is k's namespace, so k should be released before t.

I haven't checked that the above actually is the problem here, but it might be.
Possibly walking the symbols in reverse order to release them would fix this.

Regarding the patches posted, if sym->refs < 0 is true, then the memory for sym
has already been released and may be garbage (including sym->refs).  A crash is
as good as anything else at this point IMHO.

Reply via email to