From: Felipe Contreras <felipe.contreras@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, "René Scharfe" <rene.scharfe@lsrfire.ath.cx>,
"Nguyễn Thái Ngọc" <pclouds@gmail.com>,
"Adam Spiers" <git@adamspiers.org>,
"Ramkumar Ramachandra" <artagnon@gmail.com>,
"Stephen Boyd" <sboyd@codeaurora.org>
Subject: Re: [PATCH 3/4] unpack-trees: plug a memory leak
Date: Sun, 2 Jun 2013 17:45:06 -0500 [thread overview]
Message-ID: <CAMP44s2WSmu-JfKFPpNyQzDMfULMy9hCVb9Tu_Qd_bcKotOYjQ@mail.gmail.com> (raw)
In-Reply-To: <7vehckma34.fsf@alter.siamese.dyndns.org>
On Sun, Jun 2, 2013 at 5:17 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> On Sun, Jun 2, 2013 at 2:33 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>>
>>>> Before overwriting the destination index, first let's discard it's
>>>> contents.
>>>>
>>>> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
>>>> ---
>>>> unpack-trees.c | 4 +++-
>>>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/unpack-trees.c b/unpack-trees.c
>>>> index ede4299..eff2944 100644
>>>> --- a/unpack-trees.c
>>>> +++ b/unpack-trees.c
>>>> @@ -1146,8 +1146,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
>>>>
>>>> o->src_index = NULL;
>>>> ret = check_updates(o) ? (-2) : 0;
>>>> - if (o->dst_index)
>>>> + if (o->dst_index) {
>>>> + discard_index(o->dst_index);
>>>> *o->dst_index = o->result;
>>>> + }
>>>
>>> I seem to recall that many callers set src_index and dst_index to
>>> the same istate, and expect that the original istate pointed by the
>>> src_index to remain usable. Is it safe to discard it like this at
>>> this point?
>>
>> Who expects that?
>
> The patch you posted expects that no such caller depends on
> src_index being left alone by the call, and I was asking if that
> expectantion holds, i.e. if it is safe to discard.
No, it expects that no caller depends on dst_index being left alone.
> I think your answer can be one of "Yes, it is safe, as no current
> caller does so", "I dunno, I did not check", or "No, this and that
> caller need to be adjusted".
If what you say is true, it would not be safe, but AFAIK what you said
is not true, so it is safe. I wouldn't have sent the patch otherwise.
--
Felipe Contreras
next prev parent reply other threads:[~2013-06-02 22:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-30 11:58 [PATCH 0/4] cherry-pick: fix memory leaks Felipe Contreras
2013-05-30 11:58 ` [PATCH 1/4] commit: reload cache properly Felipe Contreras
2013-05-30 12:17 ` Thomas Rast
2013-05-30 12:35 ` Felipe Contreras
2013-05-30 12:58 ` Thomas Rast
2013-05-30 13:07 ` Felipe Contreras
2013-06-01 9:09 ` Duy Nguyen
2013-06-01 11:02 ` [PATCH] Test 'commit --only' after 'checkout --orphan' Thomas Rast
2013-05-30 13:08 ` [PATCH 1/4] commit: reload cache properly Duy Nguyen
2013-05-30 11:58 ` [PATCH 2/4] read-cache: plug small memory leak Felipe Contreras
2013-05-30 11:58 ` [PATCH 3/4] unpack-trees: plug a " Felipe Contreras
2013-06-02 19:33 ` Junio C Hamano
2013-06-02 19:51 ` Felipe Contreras
2013-06-02 22:17 ` Junio C Hamano
2013-06-02 22:45 ` Felipe Contreras [this message]
2013-05-30 11:58 ` [PATCH 4/4] unpack-trees: free created cache entries Felipe Contreras
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=CAMP44s2WSmu-JfKFPpNyQzDMfULMy9hCVb9Tu_Qd_bcKotOYjQ@mail.gmail.com \
--to=felipe.contreras@gmail.com \
--cc=artagnon@gmail.com \
--cc=git@adamspiers.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
--cc=rene.scharfe@lsrfire.ath.cx \
--cc=sboyd@codeaurora.org \
/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).