Skip to content

Commit 40f57ee

Browse files
brandb97gitster
authored andcommitted
t5333: test memory leak when use pseudo-merge in boundary traversal
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 249b101 commit 40f57ee

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

t/t5333-pseudo-merge-bitmaps.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,4 +445,24 @@ test_expect_success 'pseudo-merge closure' '
445445
)
446446
'
447447

448+
test_expect_success 'use pseudo-merge in boundary traversal' '
449+
git init pseudo-merge-boundary-traversal &&
450+
(
451+
cd pseudo-merge-boundary-traversal &&
452+
453+
git config bitmapPseudoMerge.test.pattern refs/ &&
454+
git config bitmapPseudoMerge.test.threshold now &&
455+
git config bitmapPseudoMerge.test.stableThreshold now &&
456+
export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1 &&
457+
458+
test_commit A &&
459+
git repack -adb &&
460+
test_commit B &&
461+
462+
echo '1' >expect &&
463+
git rev-list --count --use-bitmap-index HEAD~1..HEAD >actual &&
464+
test_cmp expect actual
465+
)
466+
'
467+
448468
test_done

0 commit comments

Comments
 (0)