[Bug fortran/94109] [8/9/10/11 Regression] Memory leak introduced in 8.3.0->8.3.1

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Jun 14 11:45:25 GMT 2020


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

--- Comment #16 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Thomas Kथà¤nig
<tkoenig@gcc.gnu.org>:

https://gcc.gnu.org/g:0c39742d618bad5ab5b9dc8ae040612a61e92103

commit r10-8299-g0c39742d618bad5ab5b9dc8ae040612a61e92103
Author: Thomas Koenig <tkoenig@gcc.gnu.org>
Date:   Sun Jun 14 13:39:43 2020 +0200

    When avoiding double deallocation, look at namespace, expression and
component.

    Our finalization handling is a mess.  Really, we should get to try and get
    this fixed for gcc 11.

    In the meantime, here is a patch which fixes a regression I introduced
    when fixing a regression with a memory leak.  The important thing
    here is to realize that we do not need to finalize (and deallocate)
    multiple times for the same expression and the same component
    in the same namespace.  It might cause code size regressions, but
    better big code than wrong code...

    Backported from r11-1296-g1af22e455584ef5fcad2b4474c1efc3fd26f6cb3 .

    gcc/fortran/ChangeLog:

            PR fortran/94109
            * class.c (finalize_component): Return early if finalization has
            already happened for expression and component within namespace.
            * gfortran.h (gfc_was_finalized): New type.
            (gfc_namespace): Add member was_finalzed.
            (gfc_expr): Remove finalized.
            * symbol.c (gfc_free_namespace): Free was_finalized.

    gcc/testsuite/ChangeLog:

            PR fortran/94109
            * gfortran.dg/finalize_34.f90: Adjust free counts.
            * gfortran.dg/finalize_36.f90: New test.


More information about the Gcc-bugs mailing list