From patchwork Thu Aug 1 10:40:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13750144 Received: from fout5-smtp.messagingengine.com (fout5-smtp.messagingengine.com [103.168.172.148]) (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 C62F5170A28 for ; Thu, 1 Aug 2024 10:41:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.148 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722508863; cv=none; b=SYMFgXivSG52IHobTLK6Zu4uN4d7bwFxIaUHWjVloJPCx9IufFZpg6lwzmaW2XkdtklvwFcZjqBxx2mZTL181wEon559xIa4jiqLGEzE9qSu3NyJbzhbms/WS1GAlnQ5pEJSohMwTTt3Uj6gMHc0VYRvn9AFdavDLb2AaZWUynA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722508863; c=relaxed/simple; bh=the81HxUmoAVHf5JbMB32UcDmpzJ/f6f6ORfQW/KCqM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tax9RlJHhqXocGriOMlj+noedkiucqvul1CLZx09m7cZJxgrIOJW296C48utvd5ERK67j5FBWtWCA2LNQgH1tUXNRR12R4dwOmxqceNllsyTjpD50HzaJ1pZzr9bFeIbiCoP0Aki3dxBca8TyOyl4drdxDOzOnrT1Ou2gMj20To= 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=jj9zlveQ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=sYMmMkUh; arc=none smtp.client-ip=103.168.172.148 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="jj9zlveQ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="sYMmMkUh" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id D9E761388060; Thu, 1 Aug 2024 06:41:00 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 01 Aug 2024 06:41:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc: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=fm3; t=1722508860; x=1722595260; bh=pfbo+hNIjJ Oa1RRetvGydDVX1nV0SUgcmw3J9gYkWuU=; b=jj9zlveQfwerEyxHZgkiOoay4K 7fE0/uJ9+osXG9uJbg3WfGHqQ1itEMofOf/8z5AAcVFvSCt6Pal4pktsSVN3oiZ9 2sAYxFatqZAnkrPVKTNSZMG2DhQGUeKjKR7M1//Syu7zTYz3m2JwtNOcyv5oe6W8 R8Loup0E1oQcHENXyd3pNCqT23BpihG3+QjCaEZJ/ZVVfeJMvU7uL4O4uEZsKvl9 xuIsk4N7S2ZsnHl7+rbtqyzaq+/pLwZ8MTaR46N2kj6OTHySRAb0I8iUHpXQMfg6 dpHnsjB+6HAWSd/XTJSvij9I3jdy1CZdamMXKLgDAQJYyMq7UReTeHppZICg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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= fm3; t=1722508860; x=1722595260; bh=pfbo+hNIjJOa1RRetvGydDVX1nV0 SUgcmw3J9gYkWuU=; b=sYMmMkUh4BV6iZD4bSfJz9KQx3kgRY/Jz6cg+kWDVZWg djAhFUWt04OYIviIULDsUdqWVi1ParercUqX2ZWohuTTwub8ByoNtqbrwVDKGJ/U 46YpcHaveBJopemKpVKFYTqry0QD4bx95nC8ZSpeKnwfzSCOiR/HvoQa4BvyBEVk Zxp2j3FmlRGaOQK41+1O7bL23mubBz8y3dnBgP7yT5MnIAhT2VogSR4F7g+6ccNK C9wytEJzQeH4eVVpmXPpqi9cZ74GLb0HyjqAri+QHj+0B+EdbRvMkomKWabyvplV WL3PgO5HSMzBMbghUXB0Q7EUfCIw8YgKrXSCJWfcVQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrjeekgdefudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrghtrhhi tghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrh hnpeeukedtvedtffevleejtefgheehieegkeeluddvfeefgeehgfeltddtheejleffteen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesph hkshdrihhmpdhnsggprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Aug 2024 06:40:59 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 1ec928ab (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 1 Aug 2024 10:39:27 +0000 (UTC) Date: Thu, 1 Aug 2024 12:40:56 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Karthik Nayak , Taylor Blau , Junio C Hamano , =?utf-8?b?UnViw6lu?= Justo Subject: [PATCH v2 20/24] t/test-repository: fix leaking repository Message-ID: 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: The test-repository test helper zeroes out `the_repository` such that it can be sure that our codebase only ends up using the supplied repository that we initialize in the respective helper functions. This does cause memory leaks though as the data that `the_repository` has been holding onto is not referenced anymore. Fix this by calling `repo_clear()` instead. Signed-off-by: Patrick Steinhardt --- t/helper/test-repository.c | 4 ++-- t/t5318-commit-graph.sh | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/t/helper/test-repository.c b/t/helper/test-repository.c index c6a074df3d..63c37de33d 100644 --- a/t/helper/test-repository.c +++ b/t/helper/test-repository.c @@ -19,7 +19,7 @@ static void test_parse_commit_in_graph(const char *gitdir, const char *worktree, setup_git_env(gitdir); - memset(the_repository, 0, sizeof(*the_repository)); + repo_clear(the_repository); if (repo_init(&r, gitdir, worktree)) die("Couldn't init repo"); @@ -49,7 +49,7 @@ static void test_get_commit_tree_in_graph(const char *gitdir, setup_git_env(gitdir); - memset(the_repository, 0, sizeof(*the_repository)); + repo_clear(the_repository); if (repo_init(&r, gitdir, worktree)) die("Couldn't init repo"); diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh index a2b4442660..2916c07e3c 100755 --- a/t/t5318-commit-graph.sh +++ b/t/t5318-commit-graph.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='commit graph' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-chunk.sh