From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Emily Noneman" <emily.noneman@gmail.com>,
"Derrick Stolee" <derrickstolee@github.com>,
"Jeff King" <peff@peff.net>,
"Paul Horn" <git@knutwalker.engineer>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH] revision.c: set-up "index_state.repo", don't segfault in pack-objects
Date: Fri, 5 Aug 2022 16:24:34 +0200 [thread overview]
Message-ID: <patch-1.1-3ff17707481-20220805T141816Z-avarab@gmail.com> (raw)
In-Reply-To: <CAKvVO18RVye=PkBRv=trj2GHh8ccGKL5j0mMq2eHQ1SX=wsr8A@mail.gmail.com>
Narrowly fix a segfault that's been reported against pack-objects at
[1] and [2].
This fixes a segfault in "git pack-objects", see a reports at [1] and
[2]. In that case we'd go through the add_index_objects_to_pending()
codepath being modified here, and eventually call into
new_untracked_cache().
We'd then segfault in new_untracked_cache_flags() as we tried to use a
NULL "repo" extracted from the "struct index_state".
The segfault we ran into there is only a symptom of a much bigger
problem, namely that we have various "struct index_state" variables
constructed in various places, and then call into functions that might
expect to have a non-NULL "repo" member. In follow-up work we'll fix
that more general problem, but let's just fix the segfault for now.
1. https://lore.kernel.org/git/977a6e0e-251c-4fa5-8b3b-fa3e2a761926@www.fastmail.com/
2. https://lore.kernel.org/git/ecb6fa27-b918-4234-8e44-13c2a3e76e07@gmail.com/
Reported-by: Paul Horn <git@knutwalker.engineer>
Reported-by: Emily Noneman <emily.noneman@gmail.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
On Thu, Aug 04 2022, Emily Noneman wrote:
> Ævar Arnfjörð Bjarmason, your patch fixed the issue for me! Thank you!
Thanks, would you mind testing this more narrow fix, I think it should
fix the segfault too, but let's be sure & confirm it.
I haven't (and haven't really tried) to come up with a regression fix
for this. I have changes that come after this which extensively test
the same issue elsewhere, so maybe it's not needed...
revision.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/revision.c b/revision.c
index 87f1c117d13..48c2f1b91a8 100644
--- a/revision.c
+++ b/revision.c
@@ -1775,7 +1775,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned int flags)
worktrees = get_worktrees();
for (p = worktrees; *p; p++) {
struct worktree *wt = *p;
- struct index_state istate = { NULL };
+ struct index_state istate = { .repo = revs->repo };
if (wt->is_current)
continue; /* current index already taken care of */
--
2.37.1.1283.g2c56c4202c5
next prev parent reply other threads:[~2022-08-05 14:25 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 ` Ævar Arnfjörð Bjarmason [this message]
2022-08-05 14:48 ` [PATCH] revision.c: set-up "index_state.repo", don't segfault in pack-objects 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
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=patch-1.1-3ff17707481-20220805T141816Z-avarab@gmail.com \
--to=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 \
--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).