git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git 2.16.0 segfaults on clone of specific repo

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jan 19, 2018, 02:47 UTC
Message-ID
<20180119024738.GA222163@genre.crustytoothpaste.net>
In-Reply-To
<CAPig+cTkBEGyoS93GYCtoDgccTF_UixqBkVTExg7Zf0M1J7KRQ@mail.gmail.com>
On Thu, Jan 18, 2018 at 07:15:56PM -0500, Eric Sunshine wrote:
Show 21 quoted lines
> [+cc:brian]
> 
> On Thu, Jan 18, 2018 at 3:55 PM, Александр Булаев
> <aleks.bulaev@gmail.com> wrote:
> > I found that git 2.16.0 segfaults on clone of vim-colorschemes repo.
> >
> > (lldb) run
> > Process 25643 launched: '/usr/local/bin/git' (x86_64)
> > Cloning into 'vim-colorschemes'...
> > remote: Counting objects: 1457, done.
> > remote: Total 1457 (delta 0), reused 0 (delta 0), pack-reused 1457
> > Receiving objects: 100% (1457/1457), 1.43 MiB | 289.00 KiB/s, done.
> > Resolving deltas: 100% (424/424), done.
> > Process 25643 stopped
> > * thread #1, queue = 'com.apple.main-thread', stop reason =
> > EXC_BAD_ACCESS (code=1, address=0x48)
> 
> I can confirm that this crashes on MacOS; it does not crash on Linux or BSD.
> 
> git-bisect places blame on eb0ccfd7f5 (Switch empty tree and blob
> lookups to use hash abstraction, 2017-11-12).

I unfortunately don't have a macOS system to test with, and I've compiled with both gcc and clang on my Debian system and, as you mentioned, it doesn't fail there.

I have a guess about what the problem might be. Can you try this patch and see if it fixes things?

-- >8 --
From 10b690241619a452634b31fbc5ccd054a4f6e5ec Mon Sep 17 00:00:00 2001
From: "brian m. carlson" <sandals@crustytoothpaste.net>
Date: Sun, 14 Jan 2018 18:26:29 +0000
Subject: [PATCH] repository: pre-initialize hash algo pointer

There are various git subcommands (among them, clone) which don't set up the repository but end up needing to have information about the hash algorithm in use. In the future, we can add a command line option for this or read it from the configuration, but until we're ready to expose that functionality to the user, simply initialize the repository structure to use the current hash algorithm, SHA-1.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 repository.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/repository.c b/repository.c
index 998413b8bb..f66fcb1342 100644
--- a/repository.c
+++ b/repository.c
@@ -5,7 +5,7 @@
 
 /* The main repository */
 static struct repository the_repo = {
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, NULL, 0, 0
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, &hash_algos[GIT_HASH_SHA1], 0, 0
 };
 struct repository *the_repository = &the_repo;
 
-- 
2.16.0.rc2.280.g09355b536d
-- >8 --
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204
Previous: Eric SunshineNext: Eric Sunshine
Message 4 of 33 in “git 2.16.0 segfaults on clone of specific repo”
  1. Александр БулаевJan 18, 2018
  2. Randall S. BeckerJan 18, 2018
  3. Eric SunshineJan 19, 2018
  4. brian m. carlsonJan 19, 2018
  5. Eric SunshineJan 19, 2018
  6. Randall S. BeckerJan 19, 2018
  7. brian m. carlsonJan 19, 2018
  8. Duy NguyenJan 19, 2018
  9. Eric SunshineJan 19, 2018
  10. Duy NguyenJan 19, 2018
  11. Eric SunshineJan 19, 2018
  12. Todd ZullingerJan 19, 2018
  13. Eric SunshineJan 20, 2018
  14. brian m. carlsonJan 19, 2018
  15. Eric SunshineJan 20, 2018
  16. brian m. carlsonJan 20, 2018
  17. Eric SunshineJan 20, 2018
  18. repository: pre-initialize hash algo pointerbrian m. carlson, Jan 19, 2018
  19. Eric SunshineJan 19, 2018
  20. Junio C HamanoJan 19, 2018
  21. Eric SunshineJan 19, 2018
  22. Junio C HamanoJan 19, 2018
  23. brian m. carlsonJan 19, 2018
  24. Junio C HamanoJan 20, 2018
  25. Eric SunshineJan 20, 2018
  26. t: add clone test for files differing only in casebrian m. carlson, Jan 20, 2018
  27. Eric SunshineJan 21, 2018
  28. Junio C HamanoJan 21, 2018
  29. Eric SunshineJan 21, 2018
  30. Eric SunshineJan 21, 2018
  31. brian m. carlsonJan 21, 2018
  32. Duy NguyenJan 21, 2018
  33. Eric SunshineJan 21, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.