git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Tribo Dar <3bodar@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [BUG] Segmentation fault in git v2.41.0.rc1
Date: Wed, 24 May 2023 10:47:13 -0400	[thread overview]
Message-ID: <ZG4jcceXn2G6Xic0@nand.local> (raw)
In-Reply-To: <CACJVABb8tvgXAowgtHLrC6Uau8Q03VRFu1m7K91SJwjvufqXYw@mail.gmail.com>

Hi Tribo,

On Wed, May 24, 2023 at 06:59:55AM +0000, Tribo Dar wrote:
> Running `git submodule update` after commenting out the url setting in both
> .gitmodules and the corresponding section for the submodule in .git/config
> results in a segmentation fault instead of a suitable error message.

Thanks for reporting. I was able to bisect this with the following
bisection script:

--- >8 ---
#!/bin/sh

rm -fr clone

if ! test -d repo
then
    git init repo
    (
        cd repo

        git submodule add git@github.com:ttaylorr/dotfiles.git
        git add --all .
        git commit -m "initial commit"
    )
fi

git.compile clone repo clone
(
    cd clone

    git submodule init
    sed -ie 's/\turl = git@/#\0/g' .gitmodules .git/config

    git.compile submodule update
    test $? -gt 128 && exit 1

    exit 0
)
--- 8< ---

which points to e0a862fdaf (submodule helper: convert relative URL to
absolute URL if needed, 2018-10-16) as the culprit. The fix appears to
be something like:

--- 8< ---
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 6bf8d666ce..98ee7697f3 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2024,8 +2024,9 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
 	strbuf_reset(&sb);
 	strbuf_addf(&sb, "submodule.%s.url", sub->name);
 	if (repo_config_get_string_tmp(the_repository, sb.buf, &url)) {
-		if (starts_with_dot_slash(sub->url) ||
-		    starts_with_dot_dot_slash(sub->url)) {
+		if (sub && sub->url &&
+		    (starts_with_dot_slash(sub->url) ||
+		     starts_with_dot_dot_slash(sub->url))) {
 			url = resolve_relative_url(sub->url, NULL, 0);
 			need_free_url = 1;
 		} else
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index eae6a46ef3..c97c543dd8 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -1351,6 +1351,22 @@ test_expect_success 'clone active submodule without submodule url set' '
 	)
 '

+test_expect_success 'update submodules without url set in .gitconfig' '
+	test_when_finished "rm -rf multisuper_clone" &&
+	git clone file://"$pwd"/multisuper multisuper_clone &&
+
+	git -C multisuper_clone submodule init &&
+	for s in sub0 sub1 sub2 sub3
+	do
+		key=submodule.$s.url &&
+		git -C multisuper_clone config --local --unset $key &&
+		git -C multisuper_clone config --file .gitmodules --unset $key || return 1
+	done &&
+
+	test_must_fail git -C multisuper_clone submodule update 2>err &&
+	grep "option .url. requires a value" err
+'
+
 test_expect_success 'clone --recurse-submodules with a pathspec works' '
 	test_when_finished "rm -rf multisuper_clone" &&
 	cat >expected <<-\EOF &&
--- >8 ---

I'll clean it up and submit it as a patch shortly.

Thanks,
Taylor

  reply	other threads:[~2023-05-24 14:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24  6:59 [BUG] Segmentation fault in git v2.41.0.rc1 Tribo Dar
2023-05-24 14:47 ` Taylor Blau [this message]
2023-05-24 16:02   ` [PATCH] builtin/submodule--helper.c: handle missing submodule URLs Taylor Blau
2023-05-24 16:25     ` [PATCH v2] " Taylor Blau
2023-05-24 18:48       ` Eric Sunshine
2023-05-24 19:50         ` Taylor Blau
2023-05-24 19:51     ` [PATCH v3] " Taylor Blau
2023-05-24 20:29       ` René Scharfe
2023-05-24 20:36         ` Taylor Blau
2023-05-24 20:33       ` Jeff King
2023-05-24 22:58     ` [PATCH] " Jeff King
2023-05-24 20:25   ` [BUG] Segmentation fault in git v2.41.0.rc1 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=ZG4jcceXn2G6Xic0@nand.local \
    --to=me@ttaylorr.com \
    --cc=3bodar@gmail.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.
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).