git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Olsen <andrew.olsen@koordinates.com>
To: git@vger.kernel.org
Subject: [BUG] git rev-list --missing=allow-promisor
Date: Thu, 11 Aug 2022 09:33:54 +1200	[thread overview]
Message-ID: <CAPJmHpVssKshapGYDF-ifU1fts-jFTC-HqxnjN8meSMP3weB4g@mail.gmail.com> (raw)

Steps to reproduce:
1. Create a git repository with missing+promised blobs.
For example, I did this:
git clone git@github.com:git/git.git git-no-blobs --filter=blob:none
--depth=1 --bare

--filter=blob:none - don't fetch any blobs
--depth=1 - we don't need git's entire history, just one commit is fine
--bare - this avoids git fetching any blobs as part of the checkout operation

2. In this repository, run:
git rev-list HEAD --objects --missing=allow-promisor

Expected outcome:
git rev-list prints the paths and OIDs of all the objects

Actual outcome:
Any of the following:
a) git rev-list prints the paths and OIDs of all the objects
b) git rev-list fails with "fatal: malformed mode in tree entry"
c) git rev-list fails with "fatal: too-short tree object"

Diagnosis:
With missing=allow-promisor, when git encounters a missing object, it
calls is_promisor on it, which in turn calls add_promisor_object on
lots of things.
In this line in add_promisor_object, the buffer of the tree that we
are currently traversing is freed:
https://github.com/git/git/blob/master/packfile.c#L2242
This clearly causes problems but not in a deterministic way.

             reply	other threads:[~2022-08-10 21:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-10 21:33 Andrew Olsen [this message]
2022-08-11  8:12 ` [BUG] git rev-list --missing=allow-promisor Jeff King
2022-08-14  6:29   ` [PATCH] is_promisor_object(): fix use-after-free of tree buffer Jeff King
2022-08-15  5:32     ` Junio C Hamano
2022-08-15 22:53       ` Jeff King

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=CAPJmHpVssKshapGYDF-ifU1fts-jFTC-HqxnjN8meSMP3weB4g@mail.gmail.com \
    --to=andrew.olsen@koordinates.com \
    --cc=git@vger.kernel.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).