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

--- Comment #31 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Bernhard Reutner-Fischer
<al...@gcc.gnu.org>:

https://gcc.gnu.org/g:8875a92d31329ae52b734683784c4b054839a661

commit r12-5073-g8875a92d31329ae52b734683784c4b054839a661
Author: Bernhard Reutner-Fischer <al...@gcc.gnu.org>
Date:   Fri Oct 12 23:57:21 2018 +0200

    Fortran: Fix memory leak in finalization wrappers [PR68800]

    If a finalization is not required we created a namespace containing
    formal arguments for an internal interface definition but never used
    any of these. So the whole sub_ns namespace was not wired up to the
    program and consequently was never freed. The fix is to simply not
    generate any finalization wrappers if we know that it will be unused.
    Note that this reverts back to the original r190869
    (8a96d64282ac534cb597f446f02ac5d0b13249cc) handling for this case
    by reverting this specific part of r194075
    (f1ee56b4be7cc3892e6ccc75d73033c129098e87) for PR fortran/37336.

    valgrind summary for e.g.
    gfortran.dg/abstract_type_3.f03 and gfortran.dg/abstract_type_4.f03
    where ".orig" is pristine trunk and ".mine" contains this fix:

    at3.orig.vg:LEAK SUMMARY:
    at3.orig.vg-   definitely lost: 8,460 bytes in 11 blocks
    at3.orig.vg-   indirectly lost: 13,288 bytes in 55 blocks
    at3.orig.vg-     possibly lost: 0 bytes in 0 blocks
    at3.orig.vg-   still reachable: 572,278 bytes in 2,142 blocks
    at3.orig.vg-        suppressed: 0 bytes in 0 blocks
    at3.orig.vg-
    at3.orig.vg-Use --track-origins=yes to see where uninitialised values come
from
    at3.orig.vg-ERROR SUMMARY: 38 errors from 33 contexts (suppressed: 0 from
0)
    --
    at3.mine.vg:LEAK SUMMARY:
    at3.mine.vg-   definitely lost: 344 bytes in 1 blocks
    at3.mine.vg-   indirectly lost: 7,192 bytes in 18 blocks
    at3.mine.vg-     possibly lost: 0 bytes in 0 blocks
    at3.mine.vg-   still reachable: 572,278 bytes in 2,142 blocks
    at3.mine.vg-        suppressed: 0 bytes in 0 blocks
    at3.mine.vg-
    at3.mine.vg-ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
    at3.mine.vg-ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
    at4.orig.vg:LEAK SUMMARY:
    at4.orig.vg-   definitely lost: 13,751 bytes in 12 blocks
    at4.orig.vg-   indirectly lost: 11,976 bytes in 60 blocks
    at4.orig.vg-     possibly lost: 0 bytes in 0 blocks
    at4.orig.vg-   still reachable: 572,278 bytes in 2,142 blocks
    at4.orig.vg-        suppressed: 0 bytes in 0 blocks
    at4.orig.vg-
    at4.orig.vg-Use --track-origins=yes to see where uninitialised values come
from
    at4.orig.vg-ERROR SUMMARY: 18 errors from 16 contexts (suppressed: 0 from
0)
    --
    at4.mine.vg:LEAK SUMMARY:
    at4.mine.vg-   definitely lost: 3,008 bytes in 3 blocks
    at4.mine.vg-   indirectly lost: 4,056 bytes in 11 blocks
    at4.mine.vg-     possibly lost: 0 bytes in 0 blocks
    at4.mine.vg-   still reachable: 572,278 bytes in 2,142 blocks
    at4.mine.vg-        suppressed: 0 bytes in 0 blocks
    at4.mine.vg-
    at4.mine.vg-ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)
    at4.mine.vg-ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)

    gcc/fortran/ChangeLog:

    2018-10-12  Bernhard Reutner-Fischer  <al...@gcc.gnu.org>

            PR fortran/68800
            * class.c (generate_finalization_wrapper): Do not leak
            finalization wrappers if they will not be used.
            * expr.c (gfc_free_actual_arglist): Formatting fix.
            * gfortran.h (gfc_free_symbol): Pass argument by reference.
            (gfc_release_symbol): Likewise.
            (gfc_free_namespace): Likewise.
            * symbol.c (gfc_release_symbol): Adjust acordingly.
            (free_components): Set procedure pointer components
            of derived types to NULL after freeing.
            (free_tb_tree): Likewise.
            (gfc_free_symbol): Set sym to NULL after freeing.
            (gfc_free_namespace): Set namespace to NULL after freeing.

Reply via email to