git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/2] t5333: test memory leak when use pseudo-merge in boundary traversal

From
Lidong Yan via GitGitGadget <gitgitgadget@gmail.com>
Date
May 30, 2025, 18:14 UTC
Message-ID
<56b24d681cbcedaf5c03c89eee582d554a0894b7.1748628847.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1977.v2.git.git.1748628846.gitgitgadget@gmail.com>
From: Lidong Yan <502024330056@smail.nju.edu.cn>

In pack-bitmap.c:find_boundary_objects(), the roots_bitmap is only freed if cascade_pseudo_merges_1() fails. Otherwise, it leaks, leading to a memory leak that currently lacks a dedicated test to detect it.

To trigger this leak, we need a pseudo-merge whose size is equal to or smaller than roots_bitmap (which corresponds to the set of "haves" commits in prepare_bitmap_walk()). To do this, we can create two commits: A and B. Add A to the pseudo-merge list and perform a traversal over the range A..B. In this scenario, the "haves" set will be {A}, and cascade_pseudo_merges_1() will succeed — thereby exposing the leak due to the missing roots_bitmap cleanup.

Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
---
 t/t5333-pseudo-merge-bitmaps.sh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff --git a/t/t5333-pseudo-merge-bitmaps.sh b/t/t5333-pseudo-merge-bitmaps.sh
index 56674db562f9..5e263fce50a7 100755
--- a/t/t5333-pseudo-merge-bitmaps.sh
+++ b/t/t5333-pseudo-merge-bitmaps.sh
@@ -445,4 +445,24 @@ test_expect_success 'pseudo-merge closure' '
 	)
 '
 
+test_expect_success 'use pseudo-merge in boundary traversal' '
+	git init pseudo-merge-boundary-traversal &&
+	(
+		cd pseudo-merge-boundary-traversal &&
+
+		git config bitmapPseudoMerge.test.pattern refs/ &&
+		git config bitmapPseudoMerge.test.threshold now &&
+		git config bitmapPseudoMerge.test.stableThreshold now &&
+		export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1 &&
+
+		test_commit A &&
+		git repack -adb &&
+		test_commit B &&
+
+		echo '1' >expect &&
+		git rev-list --count --use-bitmap-index HEAD~1..HEAD >actual &&
+		test_cmp expect actual
+	)
+'
+
 test_done
-- 
gitgitgadget
Previous: Lidong Yan via GitGitGadgetNext: Junio C Hamano
Message 5 of 28 in “pack-bitmap: remove checks before bitmap_free”
  1. pack-bitmap: remove checks before bitmap_freeLidong Yan via GitGitGadget, May 25, 2025
  2. Patrick SteinhardtMay 26, 2025
  3. lidongyanMay 26, 2025
  4. 0/2 pack-bitmap: remove checks before bitmap_freeLidong Yan via GitGitGadget, May 30, 2025
  5. 2/2 t5333: test memory leak when use pseudo-merge in boundary traversalLidong Yan via GitGitGadget, May 30, 2025
  6. Junio C HamanoMay 30, 2025
  7. Eric SunshineMay 30, 2025
  8. lidongyanMay 31, 2025
  9. 1/2 pack-bitmap: remove checks before bitmap_freeLidong Yan via GitGitGadget, May 30, 2025
  10. Junio C HamanoMay 30, 2025
  11. pack-bitmap: remove checks before bitmap_freeLidong Yan via GitGitGadget, Jun 3, 2025
  12. Junio C HamanoJun 3, 2025
  13. lidongyanJun 3, 2025
  14. Junio C HamanoJun 3, 2025
  15. lidongyanJun 3, 2025
  16. Junio C HamanoJun 4, 2025
  17. lidongyanJun 4, 2025
  18. Junio C HamanoJun 4, 2025
  19. pack-bitmap: remove checks before bitmap_freeLidong Yan via GitGitGadget, Jun 3, 2025
  20. Taylor BlauJun 3, 2025
  21. lidongyanJun 4, 2025
  22. pack-bitmap: remove checks before bitmap_freeLidong Yan via GitGitGadget, Jun 5, 2025
  23. Junio C HamanoJun 5, 2025
  24. lidongyanJun 10, 2025
  25. pack-bitmap: remove checks before bitmap_freeLidong Yan via GitGitGadget, Jun 5, 2025
  26. Junio C HamanoJun 6, 2025
  27. lidongyanJun 6, 2025
  28. pack-bitmap: remove checks before bitmap_freeLidong Yan via GitGitGadget, Jun 9, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.