From patchwork Mon Jun 3 09:47:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13683535 Received: from wfout4-smtp.messagingengine.com (wfout4-smtp.messagingengine.com [64.147.123.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75F2A85622 for ; Mon, 3 Jun 2024 09:47:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717408031; cv=none; b=iMXSXPSB/9xhRUCJamq1xmTAYlLkLlCRZDgyWXemMsxQah1eGgEubW4LlrpkG0YF7tTjDXNKUkRj9P4ib2WTXhsOhafotxuLgI2++K7tciF6uFi0y0JBBJSoMIlev42Xj0uyKBazH5ovB23CVol2oziFYb6yj6UBeoJGZXO9fIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717408031; c=relaxed/simple; bh=kr45Qc6Y33+XzSlFkcuTedQv37BKI+nv1aIQzc9RN+A=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AG8htbdX+9Rwkl8H0CGzHfzx6eubpE1cDy+bacMHgWMfHvoADtqaS0RyjGpDJRkmrs0l7CwlLCOvhX0Bl6IZ73mwsEsfLue25r6VKNDN1wNAdlirufAiTqWdvkRI94HIl69ksw0I7Ms58d22mOHJ5sCovOcqzgBl8rfYeWGiv5Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=UkuXl1Cw; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=OFJSGDXk; arc=none smtp.client-ip=64.147.123.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="UkuXl1Cw"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OFJSGDXk" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.west.internal (Postfix) with ESMTP id C077B1C0008C for ; Mon, 3 Jun 2024 05:47:09 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 03 Jun 2024 05:47:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1717408029; x=1717494429; bh=hevo73as9h WobDaO/WBICETqEM+zg7WEnjuRLdMv9IY=; b=UkuXl1CwuerktT8xAkGf3Uh6F/ ARgtknBAptei0YzdYVboUn8fZQg/YM4ZHNYPukuqjRYEtGvQJh60GdJZuXV+HhlL bzhlajr9IqqqWXFtGzO3Jkw1KfDQc1nmc1rbAu+pBu7KFUuEjMY++yK1PH/5WBWv SCAgk8foIp2FdsMcIRt2Ce1rpoa8MQsD8JTYLEb/aaREVqyEbxl963vgoM+L4lwl smh9IHYCEGvkuZgIARlY/aN+KG1ZUHtk9LBdZpcx+o7zHwzKIGHzjY3Du0tikBfI HHn8tVVFDgLqWf7R8vIptWeSWcFQtQe4urXDt7ygh2zY1MKODTanLJ3Ynf+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1717408029; x=1717494429; bh=hevo73as9hWobDaO/WBICETqEM+z g7WEnjuRLdMv9IY=; b=OFJSGDXkNir/0IB2siknh+pvOygmXkWGV3kdMO/EnJ0S 1JMGZZmQej8PbHjt2L5+ZMN/FoJlAWuShlbqWGNTrpvKbIYBiBfpis9+auavCSVV pzyJ7mxOg4RzQC8jDEfi5mfgVIRiziydyaYhBCG2MWmCsM6XnGSLCP9yKm6Zqqsk e6zKwFHxrDD3HGhzQufoNwXY36Y1Tb6nmlgbyZwGBhYZxV1adfebITqNqnuqlmEW oeKKkdx0wQLiJKnlFVXOHk/sm3GhyLUnoeaRfuHeA16RBntldsT1vxclCDwU1jgq Gc3HkWFsHVlGY1ixpIDIR31bZDaDMQfgvcpAfe2OVg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelvddgvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgepudenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 3 Jun 2024 05:47:08 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 324b092e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Mon, 3 Jun 2024 09:46:44 +0000 (UTC) Date: Mon, 3 Jun 2024 11:47:06 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 09/29] builtin/rev-list: fix leaking bitmap index when calculating disk usage Message-ID: <5e01c39e357bd3f06c1312c27b1a59cd9f741fda.1717402439.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: git-rev-list(1) can speed up its object size calculations for reachable objects via a bitmap walk, if there is any bitmap. This is done in `try_bitmap_disk_usage()`, which tries to optimistically load the bitmap and then use it, if available. It never frees it though, leading to a memory leak. Fix this. Signed-off-by: Patrick Steinhardt --- builtin/rev-list.c | 2 ++ t/t6115-rev-list-du.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/builtin/rev-list.c b/builtin/rev-list.c index 77803727e0..97d077a994 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -508,6 +508,8 @@ static int try_bitmap_disk_usage(struct rev_info *revs, size_from_bitmap = get_disk_usage_from_bitmap(bitmap_git, revs); print_disk_usage(size_from_bitmap); + + free_bitmap_index(bitmap_git); return 0; } diff --git a/t/t6115-rev-list-du.sh b/t/t6115-rev-list-du.sh index c0cfda62fa..21c4a211b1 100755 --- a/t/t6115-rev-list-du.sh +++ b/t/t6115-rev-list-du.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='basic tests of rev-list --disk-usage' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # we want a mix of reachable and unreachable, as well as