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

Re: [PATCH 1/2] shallow: free local object_array allocations

From
Samo Pogačnik <samo_pogacnik@t-2.net>
Date
Jan 9, 2026, 16:21 UTC
Message-ID
<eefa06bc46f8029b68efe993da67d14e268e1bf2.camel@t-2.net>
In-Reply-To
<aVy9ZveUOg3yum2X@pks.im>

Hi Patrick, thanks a lot for the reply.

On Tue, 2026-01-06 at 08:44 +0100, Patrick Steinhardt wrote:
Show 26 quoted lines
> On Tue, Dec 09, 2025 at 06:11:19PM +0000, Samo Pogačnik via GitGitGadget
> wrote:
> > From: =?UTF-8?q?Samo=20Poga=C4=8Dnik?= <samo_pogacnik@t-2.net>
> > 
> > The local object_array 'stack' in get_shallow_commits() function
> > does not free its dynamic elements before the function returns.
> > As a result elements remain allocated and their reference forgotten.
> 
> I think the elements themselves are actually fine. We have the following
> loop:
> 
> 	while (commit || i < heads->nr || stack.nr) {
> 
> So while the stack still has entries, we'll keep on iteration.
> Furthermore, there is no `break` or early return in the loop, so we can
> sure that we actually pop every single element from the array.
> 
> That being said, what we _don't_ do is to free the array itself. So I'm
> mostly splitting hairs with how the commit message is phrased, the
> change looks correct to me.
> 
> What I'm wondering though is why we never hit this memory leak in our
> test suite. I guess the reason is simply that we ain't got enough test
> coverage around shallow clones. Have you seen this leak in the wild? And
> if so, can we add a test case that surfaces it?
> 

Actually, the test I've added with the patch 2/2 does not pass without this memory fix in linux-leaks and linux-reftable-leaks test runs.

best regards, Samo
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 4 of 27 in “shallow: handling fetch relative-deepen”
  1. 0/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Dec 9, 2025
  2. 1/2 shallow: free local object_array allocationsSamo Pogačnik via GitGitGadget, Dec 9, 2025
  3. Patrick SteinhardtJan 6, 2026
  4. Samo PogačnikJan 9, 2026
  5. Patrick SteinhardtJan 9, 2026
  6. 2/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Dec 9, 2025
  7. Patrick SteinhardtJan 6, 2026
  8. Samo PogačnikJan 9, 2026
  9. 0/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Jan 9, 2026
  10. 1/2 shallow: free local object_array allocationsSamo Pogačnik via GitGitGadget, Jan 9, 2026
  11. 2/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Jan 9, 2026
  12. Junio C HamanoJan 10, 2026
  13. 0/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Jan 10, 2026
  14. 1/2 shallow: free local object_array allocationsSamo Pogačnik via GitGitGadget, Jan 10, 2026
  15. 2/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Jan 10, 2026
  16. Kristoffer HaugsbakkJan 15, 2026
  17. 0/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Jan 16, 2026
  18. 1/2 shallow: free local object_array allocationsSamo Pogačnik via GitGitGadget, Jan 16, 2026
  19. 2/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Jan 16, 2026
  20. Patrick SteinhardtFeb 11, 2026
  21. Samo PogačnikFeb 13, 2026
  22. Samo PogačnikFeb 14, 2026
  23. Samo PogačnikFeb 15, 2026
  24. 0/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Feb 15, 2026
  25. 1/2 shallow: free local object_array allocationsSamo Pogačnik via GitGitGadget, Feb 15, 2026
  26. 2/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Feb 15, 2026
  27. Junio C HamanoFeb 20, 2026

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.