From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9749215808B for ; Wed, 14 Feb 2024 15:46:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DD976E2A2D; Wed, 14 Feb 2024 15:45:59 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C1104E2A2D for ; Wed, 14 Feb 2024 15:45:59 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A7EC2343084 for ; Wed, 14 Feb 2024 15:45:58 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 0BBB911CF for ; Wed, 14 Feb 2024 15:45:57 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1707890662.038ad1029ea574b106906380e47479db1041bee2.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/util/_async/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/util/_async/BuildLogger.py X-VCS-Directories: lib/portage/util/_async/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 038ad1029ea574b106906380e47479db1041bee2 X-VCS-Branch: master Date: Wed, 14 Feb 2024 15:45:57 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 1be55717-be9a-4665-a8ce-0d756a7e7a26 X-Archives-Hash: 8556d906a1d0803c1fbe03ab28455f68 commit: 038ad1029ea574b106906380e47479db1041bee2 Author: Zac Medico gentoo org> AuthorDate: Wed Feb 14 05:55:31 2024 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed Feb 14 06:04:22 2024 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=038ad102 BuildLogger: Fix portage.locks._open_fds memory leak The _file_close_wrapper __getattribute__ method needs to be overridden to expose its close method, otherwise the underlying file's close method is called and the closed file object remains as a memory leak in the global portage.locks._open_fds dict. For reference, see similar classes like portage.util.atomic_ofstream which overrides methods in the same way. Bug: https://bugs.gentoo.org/919072 Fixes: df212738bbb2 ("BuildLogger: Close self._stdin after fork") Signed-off-by: Zac Medico gentoo.org> lib/portage/util/_async/BuildLogger.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/portage/util/_async/BuildLogger.py b/lib/portage/util/_async/BuildLogger.py index 9f8a21ab2b..0cfc90a942 100644 --- a/lib/portage/util/_async/BuildLogger.py +++ b/lib/portage/util/_async/BuildLogger.py @@ -1,4 +1,4 @@ -# Copyright 2020-2023 Gentoo Authors +# Copyright 2020-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import functools @@ -31,6 +31,11 @@ class _file_close_wrapper(ObjectProxy): def _get_target(self): return object.__getattribute__(self, "_file") + def __getattribute__(self, attr): + if attr == "close": + return object.__getattribute__(self, attr) + return getattr(object.__getattribute__(self, "_file"), attr) + def close(self): file = object.__getattribute__(self, "_file") if not file.closed: