git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] fetch-pack: clear alternate shallow when complete

From
Duy Nguyen <pclouds@gmail.com>
Date
Feb 7, 2019, 02:32 UTC
Message-ID
<CACsJy8Ae0ZZjh8+f+TwbfJ-V9SzrHpDFyfjwScwKJj+kc7FDTQ@mail.gmail.com>
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:

Show 13 quoted lines
>
> 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.
Show 43 quoted lines
>
> 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
Previous: brian m. carlsonNext: Junio C Hamano
Message 10 of 13 in “t5702 failing under ASan on master”
  1. brian m. carlsonJan 30, 2019
  2. Duy NguyenJan 30, 2019
  3. brian m. carlsonJan 30, 2019
  4. Junio C HamanoJan 31, 2019
  5. fetch-pack: clear alternate shallow when completebrian m. carlson, Feb 4, 2019
  6. Duy NguyenFeb 4, 2019
  7. Jonathan TanFeb 5, 2019
  8. brian m. carlsonFeb 6, 2019
  9. fetch-pack: clear alternate shallow when completebrian m. carlson, Feb 6, 2019
  10. Duy NguyenFeb 7, 2019
  11. Junio C HamanoFeb 7, 2019
  12. Junio C HamanoFeb 7, 2019
  13. brian m. carlsonFeb 7, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.