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

Re: [PATCH] ref-filter: fix double free when an object is missing

From
Karthik Nayak <karthik.188@gmail.com>
Date
Nov 12, 2026, 13:44 UTC
Message-ID
<CAOLa=ZQuT5+x-Rvxcv1CSYka3aGG2nV_hPFRDTYJEGgjbLhJwA@mail.gmail.com>
In-Reply-To
<20261112-mb-ref-filter-missing-object-double-free-maint-v1-1-d6d56a3c8dbe@gitlab.com>

Mustafa Bayar via B4 Relay <devnull+mbayar.gitlab.com@kernel.org> writes:

Show 21 quoted lines
> From: Mustafa Bayar <mbayar@gitlab.com>
>
> When a ref points to a missing object, git-for-each-ref(1) may abort
> with a double free instead of reporting the missing object:
>
>     free(): double free detected in tcache 2
>
> get_object() frees `oi->content` but leaves the pointer unchanged. Since
> the expand_data structures are reused across refs, a later call can
> start with `content` pointing to a freed buffer. Then, if the object
> lookup in that call fails before it overwrites the pointer, the cleanup
> path frees the buffer a second time.
>
> a29e2e8fe (ref-filter: parse objects on demand, 2025-10-23) introduced
> this by making object lookup failures jump to the cleanup label.
> bea37f1d6 (ref-filter: fix stale parsed objects, 2025-11-04) later fixed
> a related stale-state bug by resetting `maybe_object`.
>
> Similar to `maybe_object`, reset `content` at the start of get_object().
> Add a regression test that exercises this path.
>

I had only reviewed this patch internally and we did some iterations there [1], so mostly just rubber-stamping here that it looks good to me.

Thanks for working on this!
[snip]
[1]: https://gitlab.com/gitlab-org/git/-/merge_requests/737
Previous: Mustafa Bayar via B4 RelayNext: Junio C Hamano
Message 2 of 4 in “ref-filter: fix double free when an object is missing”
  1. ref-filter: fix double free when an object is missingMustafa Bayar via B4 Relay, Nov 12, 2026
  2. Karthik NayakNov 12, 2026
  3. Junio C HamanoNov 12, 2026
  4. Karthik NayakNov 12, 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.