git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
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: Tue, 9 Aug 2022 08:54:32 -0400	[thread overview]
Message-ID: <YvJZCGyhd6KJCabi@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqo7wyzlpm.fsf@gitster.g>

On Fri, Aug 05, 2022 at 09:41:57AM -0700, Junio C Hamano wrote:

> 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.

That makes sense. I worked backwards from the guess that Martin's patch
was relevant, hence trying to trigger ENOENT on the file. Using
--no-checkout is a plausible way to get there. (And yes, the "at" is a
typo. I double-checked the script I actually ran and it did not have the
typo; not sure how I managed to introduce it via cut and paste!).

The singleton empty tree was only there in my example because "git
worktree" insists on having a starting point. Its contents shouldn't
matter either way.

Here's the test addition you mentioned, though I'm really not sure it's
adding much. The source lines for both the bug/fix and the spot where we
segfault should be identical between the two cases. It's really just
about how we ended up calling into the code.

-- >8 --
Subject: [PATCH] t7063: add another missing-index test

Commit 4447d4129d (read-cache: make `do_read_index()` always set up
`istate->repo`, 2022-07-22) fixed a case where a missing "index" file
caused us to segfault in the untracked-cache code.

We ran into another situation in the wild which caused a similar
segfault, this time with an empty worktree. These actually segfault at
the same spot (inside the index reading code), but the call path to get
there is different between the two, hence it may be worth checking both.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jeff King <peff@peff.net>
---
 t/t7063-status-untracked-cache.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh
index c1f0d95036..a0e8920ffa 100755
--- a/t/t7063-status-untracked-cache.sh
+++ b/t/t7063-status-untracked-cache.sh
@@ -990,4 +990,9 @@ test_expect_success 'empty repo (no index) and core.untrackedCache' '
 	git -C emptyrepo -c core.untrackedCache=true write-tree
 '
 
+test_expect_success 'empty worktree and core.untrackedCache' '
+	git worktree add --no-checkout empty-worktree &&
+	git -c core.untrackedCache=true gc
+'
+
 test_done
-- 
2.37.1.845.ge5d2b690ea


  parent reply	other threads:[~2022-08-09 12:54 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
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 [this message]
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=YvJZCGyhd6KJCabi@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=emily.noneman@gmail.com \
    --cc=git@knutwalker.engineer \
    --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.
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).