From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Willem Verstraeten <willem.verstraeten@gmail.com>,
git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: [PATCH 2/2] checkout: forbid "-B <branch>" from touching a branch used elsewhere
Date: Thu, 30 Nov 2023 15:22:32 +0000 [thread overview]
Message-ID: <b3532261-3cf4-4666-9cbd-4ce668cd2e49@gmail.com> (raw)
In-Reply-To: <xmqqwmu42ccb.fsf@gitster.g>
Hi Junio
On 27/11/2023 01:51, Junio C Hamano wrote:
> Phillip Wood <phillip.wood123@gmail.com> writes:
>
>> At the moment this is academic as neither of the test scripts changed
>> by this patch are leak free and so I don't think we need to worry
>> about it but it raises an interesting question about how we should
>> handle memory leaks when dying. Leaving the leak when dying means that
>> a test script that tests an expected failure will never be leak free
>> but using UNLEAK() would mean we miss a leak being introduced in the
>> successful case should the call to "free()" ever be removed.
>
> Is there a leak here? The piece of memory is pointed at by an on-stack
> variable full_ref when leak sanitizer starts scanning the heap and
> the stack just before the process exits due to die, so I do not see
> a reason to worry about this particular variable over all the other
> on stack variables we accumulated before the control reached this
> point of the code.
Oh, good point. I was thinking "we exit without calling free() so it is
leaked" but as you say the leak checker (thankfully) does not consider
it a leak as there is still a reference to the allocation on the stack.
Sorry for the noise
Phillip
> Are you worried about optimizing compilers that behave more cleverly
> than their own good to somehow lose the on-stack reference to
> full_ref while calling die_if_switching_to_a_branch_in_use()? We
> might need to squelch them with UNLEAK() but that does not mean we
> have to remove the free() we see above, and I suspect a more
> productive use of our time to solve that issue is ensure that our
> leak-sanitizing build will not triger such an unwanted optimization
> anyway.
>
> Thanks.
next prev parent reply other threads:[~2023-11-30 15:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 19:08 git checkout -B <branch> lets you checkout a branch that is already checked out in another worktree Inbox Willem Verstraeten
2023-11-23 1:28 ` Junio C Hamano
2023-11-23 5:58 ` Junio C Hamano
2023-11-23 6:00 ` [PATCH 2/2] checkout: forbid "-B <branch>" from touching a branch used elsewhere Junio C Hamano
2023-11-23 16:33 ` Phillip Wood
2023-11-23 17:09 ` Eric Sunshine
2023-11-24 1:19 ` Junio C Hamano
2023-11-27 1:51 ` Junio C Hamano
2023-11-27 21:31 ` Jeff King
2023-11-30 15:22 ` Phillip Wood [this message]
2023-12-04 12:20 ` Willem Verstraeten
2023-12-04 21:06 ` Eric Sunshine
2023-12-08 17:13 ` Junio C Hamano
2024-01-30 12:37 ` Willem Verstraeten
2024-01-30 22:30 ` Junio C Hamano
2023-11-23 22:03 ` git checkout -B <branch> lets you checkout a branch that is already checked out in another worktree Inbox Andy Koppe
2023-11-23 12:12 ` Willem Verstraeten
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=b3532261-3cf4-4666-9cbd-4ce668cd2e49@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=phillip.wood@dunelm.org.uk \
--cc=willem.verstraeten@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).