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

Re: [PATCH] pack-bitmap: remove checks before bitmap_free

From
lidongyan <502024330056@smail.nju.edu.cn>
Date
May 26, 2025, 16:05 UTC
Message-ID
<3F8C41C7-8DCF-408A-AB81-B77B46D20FC9@smail.nju.edu.cn>
In-Reply-To
<aDQO4Vkj7POztMnC@pks.im>
2025年5月26日 14:49,Patrick Steinhardt <ps@pks.im> 写道:
Show 8 quoted lines
> 
> This commit message isn't quite a convincing one. As author of a patch
> the onus falls on you to explain why the change is sensible, but even
> more importantly it also falls on you to explain why it is correct.
> 
> It is of course fine to ask for help and input, but in that case you
> should probably mark the patch accordingly, for example with the RFC
> tag.
Thank you for the suggestion. Please allow me to keep the patch in its
 current form this time. 
Show 17 quoted lines
> We know that `roots_bitmap` is always allocated via `bitmap_new()`, so
> it won't ever be a `NULL` pointer and should in theory always be free'd.
> Furthermore, we know that the pointer never escapes the local scope,
> either.
> 
> The next question would thus be: what does `cascade_pseudo_merges_1()`
> do with the bitmap? Are there situations where it does free it for us,
> or where it moves ownership of that bitmap? So let's go down the call
> chain:
> 
>  - `cascade_pseudo_merges_1()` passes it on to
>    `cascade_pseudo_merges()`.
> 
>  - `cascade_pseudo_merges()` passes it on to `apply_pseudo_merge()`.
> 
> `apply_pseudo_merge()` itself then checks whether the pseudo-merge is a
> subset of the `roots_bitmap` and, if not, ORs the pseudo-merge into it.

I would put this into commit message. I also noticed that `find_objects()` in pack-bitmap.c has similar code but without `if (cascade_pseudo_merges_1)`.

Show 5 quoted lines
> 
> None of these operations move around ownership or free the bitmap, so
> this looks like a true memory leak in case `cascade_pseudo_merges_1()`
> returns non-zero. Which would raise another question: when exactly does
> it return non-zero, and can we trigger the memory leak via a test?

Seems we need to make `bitmap_git->pseudo_merges->v[I]` contains some objects which doesn’t exist in `roots`. I’ll try to figure it out in the next patch.

Thanks Lidong

Previous: Patrick SteinhardtNext: Lidong Yan via GitGitGadget
Message 3 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.