From: Patrick Steinhardt <ps@pks.im>
To: "Onur Gündüz via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, "Onur Gündüz" <ogunduz@gmail.com>
Subject: Re: [PATCH] refs/debug: free the wrapped ref iterator
Date: Tue, 1 Dec 2026 16:19:11 +0100 [thread overview]
Message-ID: <aw7lb299-Z2Hb_uY@pks.im> (raw)
In-Reply-To: <pull.2332.git.1795664263318.gitgitgadget@gmail.com>
On Thu, Nov 26, 2026 at 03:37:43AM +0000, Onur Gündüz via GitGitGadget wrote:
> diff --git a/refs/debug.c b/refs/debug.c
> index 639db0f26e..96bf9d55d3 100644
> --- a/refs/debug.c
> +++ b/refs/debug.c
> @@ -200,7 +200,7 @@ static void debug_ref_iterator_release(struct ref_iterator *ref_iterator)
> {
> struct debug_ref_iterator *diter =
> (struct debug_ref_iterator *)ref_iterator;
> - diter->iter->vtable->release(diter->iter);
> + ref_iterator_free(diter->iter);
> trace_printf_key(&trace_refs, "iterator_abort\n");
> }
Do we maybe want to also NULL `diter->iter` to not leave the pointer
dangling? In theory that shouldn't ever be a problem as we'd free the
debug ref iterator, anyway. But it might make sense to do it regardless.
> diff --git a/t/t1405-main-ref-store.sh b/t/t1405-main-ref-store.sh
> index 6d8f401a2a..e414b61c10 100755
> --- a/t/t1405-main-ref-store.sh
> +++ b/t/t1405-main-ref-store.sh
> @@ -55,6 +55,12 @@ test_expect_success 'for_each_ref() is sorted' '
> test_cmp expected actual
> '
>
> +test_expect_success 'for_each_ref() with tracing' '
> + $RUN for-each-ref refs/heads/ >expected &&
> + GIT_TRACE_REFS=1 $RUN for-each-ref refs/heads/ >actual &&
> + test_cmp expected actual
> +'
This would of course succeed without the patch without leak sanitizer,
but our CI also runs with leak sanitizer. So this test is good enough.
Do we maybe want to verify that `GIT_TRACE_REFS` does anything by also
redirecting stderr and then doing something like `test_grep
iterator_advance`?
Thanks!
Patrick
prev parent reply other threads:[~2026-12-01 15:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 3:37 [PATCH] refs/debug: free the wrapped ref iterator Onur Gündüz via GitGitGadget
2026-12-01 15:19 ` Patrick Steinhardt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aw7lb299-Z2Hb_uY@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=ogunduz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.