git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Derrick Stolee" <derrickstolee@github.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	git@vger.kernel.org, "Emily Noneman" <emily.noneman@gmail.com>,
	"Paul Horn" <git@knutwalker.engineer>
Subject: Re: [PATCH] revision.c: set-up "index_state.repo", don't segfault in pack-objects
Date: Fri, 05 Aug 2022 09:41:57 -0700	[thread overview]
Message-ID: <xmqqo7wyzlpm.fsf@gitster.g> (raw)
In-Reply-To: <Yu02dOo4G8sy8tI6@coredump.intra.peff.net> (Jeff King's message of "Fri, 5 Aug 2022 11:25:40 -0400")

Jeff King <peff@peff.net> writes:

> Of the two patches, I think 4447d4129d is the better approach. The
> assumption in the code seems to be that do_read_index() (and thus
> read_index_from(), etc) will set up istate->repo. That patch fixes a
> corner case where we failed to do so. And with that fix, there's no need
> for the callers to set things up ahead of time. So it covers all of
> those initializers you mentioned.

Yeah, I tend to agree that Martin's fix, which is a more focused
one, is the better approach between the two.  It was merged to
the 'master' track only a few days ago.

We are at the end of the week #4 of this 12-week cycle, and we've
accumulated about two dozens of topics already on 'maint' since the
first maintenance release v2.37.1 was done, so we may have a chance
to merge Martin's fix down to 'maint' before tagging the v2.37.2
release.

One thing that may help is to add a test similar to the situation
Emily & Paul had to t7063 on top of 4447d4129d before merging it
down, perhaps?

In your reproduction, the "rm .git/index" step makes the worktree's
branch "not checked out" (the commit is empty so "worktree add" may
check out no files, and removing the index will make it as if you
did "clone --no-checkout") ...

  git init repo
  cd repo
  git commit --allow-empty -m base

  git config core.untrackedCache true
  git worktree add at
  rm .git/worktrees/wt/index

  git gc

...  but it is not something an end user is likely to do, so I am
still curious how this was triggered in real life.

Ah, OK, I think the steps can be tweaked to

      git config core.untrackedCache true
    - git worktree add at
    - rm .git/worktrees/wt/index
    + git worktree add --no-checkout wt

      git gc

i.e. (1) With "worktree add --no-checkout", there is no need to
manually remove the index file, and (2) "at" is an obvious typo of
"wt".  This does not require the history to be a singleton empty
tree, either.

And that is a less implausible thing for users to be doing, but may
still not be very common.  Perhaps the --no-checkout is a prelude to
set up a custom sparse checkout pattern, to avoid a wasteful full
tree checkout before doing so, or something?  If that is the case,
then the above sequence becomes a very plausible thing for users to
be doing.

> Emily, Paul: I'm 99% sure this will be the case given my reproduction
> above, but if you could try reproducing the problem with the current tip
> of "master" from git.git, that would confirm the findings.

Yes, indded.  That would be very helpful.

Thanks, all, for discussing the problem and its solution(s), and
thanks in advance for further testing to help the fix forward.

  reply	other threads:[~2022-08-05 16:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-12  8:51 Bugreport: pack-objects died of signal 11 Paul Horn
2022-07-14 21:37 ` Jeff King
2022-08-04 18:21   ` Emily Noneman
2022-08-04 20:14     ` Derrick Stolee
2022-08-04 21:07       ` Ævar Arnfjörð Bjarmason
2022-08-04 22:32         ` Emily Noneman
2022-08-05 14:24           ` [PATCH] revision.c: set-up "index_state.repo", don't segfault in pack-objects Ævar Arnfjörð Bjarmason
2022-08-05 14:48             ` Derrick Stolee
2022-08-05 15:25               ` Jeff King
2022-08-05 16:41                 ` Junio C Hamano [this message]
2022-08-08 18:15                   ` Emily Noneman
2022-08-09 12:55                     ` Jeff King
2022-08-09 16:56                       ` Junio C Hamano
2022-08-09 12:54                   ` Jeff King
2022-08-09 16:55                     ` 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

  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=xmqqo7wyzlpm.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=emily.noneman@gmail.com \
    --cc=git@knutwalker.engineer \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.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).