git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Christian Couder <christian.couder@gmail.com>
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Frédéric Fort" <fortfrederic@free.fr>,
	git@vger.kernel.org
Subject: Re: Segmentation fault within git read-tree
Date: Sun, 15 Jan 2023 13:35:42 -0500	[thread overview]
Message-ID: <Y8RHfjFFLRdW3WRh@coredump.intra.peff.net> (raw)
In-Reply-To: <CAP8UFD0pKZT57jpUOg7gckcr4stoq24YDB2Fu0-AwbGPrEweqg@mail.gmail.com>

On Sun, Jan 15, 2023 at 12:53:25PM +0100, Christian Couder wrote:

> From a very quick look, it seems that in setup_traverse_info() in
> tree-walk.c we do:
> 
>     static struct traverse_info dummy;
> ...
>     if (pathlen)
>         info->prev = &dummy;
> 
> but then later in debug_path() in unpack-trees.c we check
> *info->prev->name which segfaults.
> 
> I am not very familiar with this code and don't have much time right
> now, so I think I will leave it to others to investigate this further.

I'm not sure if Frédéric is seeing another segfault in practice (when
not using --debug-unpack), but yeah, it is very easy to trigger this
segfault. It does not even have to do with sparse checkouts, etc. Here's
an even more minimal example:

  git init repo
  cd repo
  touch file
  git add file
  git commit -m added
  git read-tree --debug-unpack --prefix=subtree HEAD

I was going to bisect, but it looks like it was broken all the way back
to Junio's ba655da537 (read-tree --debug-unpack, 2009-09-14).

-Peff

  reply	other threads:[~2023-01-15 18:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-14 22:14 Segmentation fault within git read-tree Frédéric Fort
2023-01-15 11:53 ` Christian Couder
2023-01-15 18:35   ` Jeff King [this message]
2023-01-15 21:49     ` Junio C Hamano

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=Y8RHfjFFLRdW3WRh@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=christian.couder@gmail.com \
    --cc=fortfrederic@free.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).