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

Re: [PATCH v2 0/6] pack-objects: create new name-hash algorithm

From
Taylor Blau <me@ttaylorr.com>
Date
Oct 4, 2024, 22:30 UTC
Message-ID
<ZwBsbW5jsFw0mxKk@nand.local>
In-Reply-To
<xmqqiku7d0ut.fsf@gitster.g>
On Fri, Oct 04, 2024 at 02:17:30PM -0700, Junio C Hamano wrote:
> t5334 still fails 8/16 subtests just like the above run, exonerating
> this topic for its breakage.
>
>   https://github.com/git/git/actions/runs/11186737635/job/31102378478#step:4:1880

This is not all too surprising, since part two of the incremental MIDX topic introduces some new leaks which were not seen by Patrick's recent leakfixes. So I expect that this broke with 9d4855eef3 (midx-write: fix leaking buffer, 2024-09-30), which marked t5534 as leak-free.

And that's true, without the patches from tb/incremental-midx-part-2. The leak stems from the fact that the 'bitmap_index' struct now has a new optional "base" pointer, which points to another 'bitmap_index' corresponding to the previous MIDX layer.

The fix is fairly straightforward, and should be limited to:
--- 8< ---
Subject: [PATCH] fixup! pack-bitmap.c: open and store incremental bitmap
 layers

The incremental MIDX bitmap work was done prior to 9d4855eef3 (midx-write: fix leaking buffer, 2024-09-30), and causes test failures in t5334 in a post-9d4855eef3 world.

The leak looks like:
    Direct leak of 264 byte(s) in 1 object(s) allocated from:
        #0 0x7f6bcd87eaca in calloc ../../../../src/libsanitizer/lsan/lsan_interceptors.cpp:90
        #1 0x55ad1428e8a4 in xcalloc wrapper.c:151
        #2 0x55ad14199e16 in prepare_midx_bitmap_git pack-bitmap.c:742
        #3 0x55ad14199447 in open_midx_bitmap_1 pack-bitmap.c:507
        #4 0x55ad14199cca in open_midx_bitmap pack-bitmap.c:704
        #5 0x55ad14199d44 in open_bitmap pack-bitmap.c:717
        #6 0x55ad14199dc2 in prepare_bitmap_git pack-bitmap.c:733
        #7 0x55ad1419e496 in test_bitmap_walk pack-bitmap.c:2698
        #8 0x55ad14047b0b in cmd_rev_list builtin/rev-list.c:629
        #9 0x55ad13f71cd6 in run_builtin git.c:487
        #10 0x55ad13f72132 in handle_builtin git.c:756
        #11 0x55ad13f72380 in run_argv git.c:826
        #12 0x55ad13f728f4 in cmd_main git.c:961
        #13 0x55ad1407d3ae in main common-main.c:64
        #14 0x7f6bcd5f0c89 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
        #15 0x7f6bcd5f0d44 in __libc_start_main_impl ../csu/libc-start.c:360
        #16 0x55ad13f6ff90 in _start (git+0x1ef90) (BuildId: 3e63cdd415f1d185b21da3035cb48332510dddce)

, and is a result of us not freeing the resources corresponding to the bitmap's base layer, if one was present.

Rectify that leak by calling the newly-introduced free_bitmap_index() function on the base layer to ensure that its resources are also freed.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 pack-bitmap.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 2b4c3972e5..fe0df2b6c3 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -3045,6 +3045,7 @@ void free_bitmap_index(struct bitmap_index *b)
 		close_midx_revindex(b->midx);
 	}
 	free_pseudo_merge_map(&b->pseudo_merges);
+	free_bitmap_index(b->base);
 	free(b);
 }

--
2.47.0.rc1.154.ge6e38f19f35.dirty
--- >8 ---

That should apply on top of 'seen' easily, and will at least fix the
leak failures you pointed out here.

When the integration branches are rewound after 2.47.0 is tagged, I'll
send a new version of this topic based on Patrick's work here.

Thanks,
Taylor
Previous: Junio C HamanoNext: Jeff King
Message 36 of 38 in “pack-objects: create new name-hash algorithm”
  1. 0/4 pack-objects: create new name-hash algorithmDerrick Stolee via GitGitGadget, Sep 9, 2024
  2. 1/4 pack-objects: add --full-name-hash optionDerrick Stolee via GitGitGadget, Sep 9, 2024
  3. Junio C HamanoSep 9, 2024
  4. Derrick StoleeSep 10, 2024
  5. 2/4 git-repack: update usage to match docsDerrick Stolee via GitGitGadget, Sep 9, 2024
  6. Junio C HamanoSep 9, 2024
  7. 3/4 p5313: add size comparison testDerrick Stolee via GitGitGadget, Sep 9, 2024
  8. 4/4 p5314: add a size test for name-hash collisionsDerrick Stolee via GitGitGadget, Sep 9, 2024
  9. Derrick StoleeSep 9, 2024
  10. Junio C HamanoSep 9, 2024
  11. Derrick StoleeSep 10, 2024
  12. Taylor BlauSep 10, 2024
  13. Derrick StoleeSep 10, 2024
  14. Jeff KingSep 11, 2024
  15. Junio C HamanoSep 10, 2024
  16. Junio C HamanoSep 10, 2024
  17. Derrick StoleeSep 10, 2024
  18. 0/6 pack-objects: create new name-hash algorithmDerrick Stolee via GitGitGadget, Sep 18, 2024
  19. 1/6 pack-objects: add --full-name-hash optionDerrick Stolee via GitGitGadget, Sep 18, 2024
  20. Junio C HamanoSep 19, 2024
  21. 2/6 repack: test --full-name-hash optionDerrick Stolee via GitGitGadget, Sep 18, 2024
  22. Junio C HamanoSep 19, 2024
  23. 3/6 pack-objects: add GIT_TEST_FULL_NAME_HASHDerrick Stolee via GitGitGadget, Sep 18, 2024
  24. Junio C HamanoSep 19, 2024
  25. Derrick StoleeSep 23, 2024
  26. 4/6 git-repack: update usage to match docsDerrick Stolee via GitGitGadget, Sep 18, 2024
  27. 5/6 p5313: add size comparison testDerrick Stolee via GitGitGadget, Sep 18, 2024
  28. Junio C HamanoSep 19, 2024
  29. Derrick StoleeSep 23, 2024
  30. Junio C HamanoSep 23, 2024
  31. 6/6 test-tool: add helper for name-hash valuesDerrick Stolee via GitGitGadget, Sep 18, 2024
  32. Patrick SteinhardtSep 24, 2024
  33. Derrick StoleeSep 25, 2024
  34. Derrick StoleeSep 18, 2024
  35. Junio C HamanoOct 4, 2024
  36. Taylor BlauOct 4, 2024
  37. Jeff KingOct 4, 2024
  38. Derrick StoleeOct 8, 2024

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.