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

Re: [PATCH] repository: pre-initialize hash algo pointer

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jan 19, 2018, 07:54 UTC
Message-ID
<CAPig+cTOw5NsSmLHYcBEidDzNyiidJ0Dw1dF227KWDL9JrASvw@mail.gmail.com>
In-Reply-To
<20180119041825.727904-1-sandals@crustytoothpaste.net>

On Thu, Jan 18, 2018 at 11:18 PM, brian m. carlson <sandals@crustytoothpaste.net> wrote:

Show 19 quoted lines
> There are various git subcommands (among them, clone) which don't set up
> the repository (that is, they lack RUN_SETUP or RUN_SETUP_GENTLY) but
> end up needing to have information about the hash algorithm in use.
> Because the hash algorithm is part of struct repository and it's only
> initialized in repository setup, we can end up dereferencing a NULL
> pointer in some cases if we call one of these subcommands and look up
> the empty blob or empty tree values.
>
> 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>
> ---
> I'm still quite mystified as to why this is working on Linux and not
> macOS, but I can only guess that compilers are just very advanced and
> have somehow concluded that we would clearly never dereference a NULL
> pointer, so they picked the only non-NULL value.

Now that we know (due to Duy's excellent detective work[1]) that the trigger is files with names differing only in case on case-insensitive filesystems, the commit message can be updated appropriately.

Show 8 quoted lines
> I haven't included a test because I have no way to reproduce the issue.
> This patch is the first from a series I'm working on where I do expand
> the use of the hash struct and therefore caused a segfault on clone, so
> I can imagine what's going on without having a way to prove it affects
> this particular case.
>
> If someone with access to macOS can provide a test, I'd be very
> grateful.

Done. Find the test here[2]. It fails without your fix on MacOS and (presumably) Windows, and succeeds with the fix.

> My apologies for the error and inconvenience.

[1]: https://public-inbox.org/git/CACsJy8BTFm_0sv=roL1OKKW=1DyU3vqD50NKyHg3KQ7G+mAepQ@mail.gmail.com/ [2]: https://public-inbox.org/git/20180119074001.GA55929@flurp.local/

Previous: brian m. carlsonNext: Junio C Hamano
Message 19 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.