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

Re: [PATCH v2] remote: plug memory leaks

From
Jeff King <peff@peff.net>
Date
Jul 25, 2026, 16:18 UTC
Message-ID
<20260725161819.GA2343104@coredump.intra.peff.net>
In-Reply-To
<xmqqpl0b12gj.fsf@gitster.g>
On Sat, Jul 25, 2026 at 09:03:24AM -0700, Junio C Hamano wrote:
Show 7 quoted lines
> * The initial iteration relied on the assumption that strings
>   borrowed from the configset subsystem will not go away, attempting
>   to plug the leak of 'instead_of[n].s' pointers without making
>   copies.  However, it turns out that all existing users other than
>   a select few make copies and do not rely on that assumption.  In
>   this version, I decided to simply follow suit, which might be
>   slightly inefficient but is vastly safer.
Heh, I was just in the middle of writing a message digging into this.

We should not rely on that assumption, because we sometimes discard the configset (e.g., when discovering the repo, or when writing a new config option). I couldn't come up with a case that fails, but I think it is mostly luck (or lack of imagination) that there is no code path that invalidates the configset between when we read the remote config and when we actually use it.

So even though in something like:
    git -c url.$PWD.insteadOf=$PWD clone $PWD dst

we end up with a state were the instead-of structs are broken, nobody is reading them at that point.

So I think this v2 is doing the right thing.
-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 5 in “remote: plug memory leaks”
  1. remote: plug memory leaksJunio C Hamano, Jul 25, 2026
  2. Junio C HamanoJul 25, 2026
  3. remote: plug memory leaksJunio C Hamano, Jul 25, 2026
  4. Jeff KingJul 25, 2026
  5. Junio C HamanoJul 25, 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.