From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 854843858409; Tue, 9 Nov 2021 20:57:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 854843858409 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/68800] Fortran FE produces many memory leaks Date: Tue, 09 Nov 2021 20:57:13 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Nov 2021 20:57:13 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D68800 --- Comment #5 from CVS Commits --- The master branch has been updated by Bernhard Reutner-Fischer : https://gcc.gnu.org/g:8875a92d31329ae52b734683784c4b054839a661 commit r12-5073-g8875a92d31329ae52b734683784c4b054839a661 Author: Bernhard Reutner-Fischer 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=3Dyes to see where uninitialised values= come from at3.orig.vg-ERROR SUMMARY: 38 errors from 33 contexts (suppressed: 0 fr= om 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=3Dyes to see where uninitialised values= come from at4.orig.vg-ERROR SUMMARY: 18 errors from 16 contexts (suppressed: 0 fr= om 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 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.=