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