git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>
Cc: Junio C Hamano <gitster@pobox.com>,
	Git Mailing List <git@vger.kernel.org>,
	Jonathan Tan <jonathantanmy@google.com>
Subject: Re: [PATCH v2] fetch-pack: clear alternate shallow when complete
Date: Thu, 7 Feb 2019 09:32:21 +0700	[thread overview]
Message-ID: <CACsJy8Ae0ZZjh8+f+TwbfJ-V9SzrHpDFyfjwScwKJj+kc7FDTQ@mail.gmail.com> (raw)
In-Reply-To: <20190206235937.201663-1-sandals@crustytoothpaste.net>

On Thu, Feb 7, 2019 at 7:00 AM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
>
> When we write an alternate shallow file in update_shallow, we write it
> into the lock file. The string stored in alternate_shallow_file is
> copied from the lock file path, but it is freed the moment that the lock
> file is closed, since we call strbuf_release to free that path.
>
> This used to work, since we did not invoke git index-pack more than
> once. However, we now do, and starting with bd0b42aed3 (fetch-pack: do
> not take shallow lock unnecessarily - 2019-01-10), we no longer reset
> this value unconditionally; consequently, we reuse the freed memory.
> Ensure we reset the value to NULL to avoid using freed memory. git
> index-pack will read the repository's shallow file, which will have been
> updated with the correct information.

The patch looks good to me.

>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
>  fetch-pack.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/fetch-pack.c b/fetch-pack.c
> index 577faa6229..a92621a388 100644
> --- a/fetch-pack.c
> +++ b/fetch-pack.c
> @@ -1272,6 +1272,8 @@ static void receive_shallow_info(struct fetch_pack_args *args,
>                 setup_alternate_shallow(&shallow_lock, &alternate_shallow_file,
>                                         NULL);
>                 args->deepen = 1;
> +       } else {
> +               alternate_shallow_file = NULL;
>         }
>  }
>
> @@ -1489,6 +1491,7 @@ static void update_shallow(struct fetch_pack_args *args,
>                         rollback_lock_file(&shallow_lock);
>                 } else
>                         commit_lock_file(&shallow_lock);
> +               alternate_shallow_file = NULL;
>                 return;
>         }
>
> @@ -1512,6 +1515,7 @@ static void update_shallow(struct fetch_pack_args *args,
>                                                 &alternate_shallow_file,
>                                                 &extra);
>                         commit_lock_file(&shallow_lock);
> +                       alternate_shallow_file = NULL;
>                 }
>                 oid_array_clear(&extra);
>                 return;
> @@ -1551,6 +1555,7 @@ static void update_shallow(struct fetch_pack_args *args,
>                 commit_lock_file(&shallow_lock);
>                 oid_array_clear(&extra);
>                 oid_array_clear(&ref);
> +               alternate_shallow_file = NULL;
>                 return;
>         }
>


-- 
Duy

  reply	other threads:[~2019-02-07  2:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30  8:58 t5702 failing under ASan on master brian m. carlson
2019-01-30 10:07 ` Duy Nguyen
2019-01-30 11:40   ` brian m. carlson
2019-01-31 18:12     ` Junio C Hamano
2019-02-04  0:06 ` [PATCH] fetch-pack: clear alternate shallow when complete brian m. carlson
2019-02-04 10:34   ` Duy Nguyen
2019-02-05 16:26     ` Jonathan Tan
2019-02-06 23:26       ` brian m. carlson
2019-02-06 23:59   ` [PATCH v2] " brian m. carlson
2019-02-07  2:32     ` Duy Nguyen [this message]
2019-02-07  2:47       ` Junio C Hamano
2019-02-07  2:53         ` Junio C Hamano
2019-02-07  4:07           ` brian m. carlson

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACsJy8Ae0ZZjh8+f+TwbfJ-V9SzrHpDFyfjwScwKJj+kc7FDTQ@mail.gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jonathantanmy@google.com \
    --cc=sandals@crustytoothpaste.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).