From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2F10D3858C66; Mon, 6 Mar 2023 20:00:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F10D3858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678132803; bh=d+K7mwavRbtDZq1IRGqW0kVA2+Flfx1I01fLs+7Ligg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GAAoB9WMJ35URF/2hI5wMNMJV1k16iBDfKlfnSnqBaUCCl91YT0cy4yhAbfCaiL4Y XPw7y+4++B5tphPEoswMitrFnI9SM/YvNUkJGk+HKv0JLJd+wM6FOtr14q2UZMvIH+ +yd5OIwANxiNWcF12UFfPUeaQalw1psa0gtSGGPI= From: "mikael at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/108925] memory leak of gfc_get_namespace result Date: Mon, 06 Mar 2023 20:00:02 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mikael at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108925 --- Comment #5 from Mikael Morin --- This does NOT improve things: diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc index 601497e0998..2d6c7b8ef73 100644 --- a/gcc/fortran/module.cc +++ b/gcc/fortran/module.cc @@ -5258,7 +5258,10 @@ read_cleanup (pointer_info *p) vtypes - their name is fine for a symtree and reduces the namespace pollution. */ st =3D gfc_find_symtree (ns->sym_root, p->u.rsym.sym->name); - if (!st) + if (st) + /* The symtree is reassigned below. */ + st->n.sym->refs--; + else st =3D gfc_new_symtree (&ns->sym_root, p->u.rsym.sym->name); }=