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

Re: SIGSEGV Error Occurs When Attempting to Unbundle Without Initializing Git Repository.

From
Jeff King <peff@peff.net>
Date
Aug 12, 2024, 11:47 UTC
Message-ID
<20240812114733.GA3732689@coredump.intra.peff.net>
In-Reply-To
<TYWP301MB0563973ECA440E7DAF0F7E89C4852@TYWP301MB0563.JPNP301.PROD.OUTLOOK.COM>
On Mon, Aug 12, 2024 at 06:57:25PM +0800, ArcticLampyrid wrote:
Show 11 quoted lines
> #### Steps to Reproduce
> I attempted to unbundle a pack but forgot to execute `git init` beforehand.
> 
> #### Expected Behavior
> An error message should have been displayed, reminding me to run `git init`.
> 
> #### Actual Behavior
> The process unexpectedly terminated with a SIGSEGV (Address boundary error).
> 
> #### Difference Between Expected and Actual Behavior
> Instead of gracefully exiting, the process terminated abruptly.

Thanks for the report, it's pretty easy to reproduce. Looks like another casualty of c8aed5e8da (repository: stop setting SHA1 as the default object hash, 2024-05-07). Author cc'd.

A sample stack trace is:
  #0  0x000055555573a93c in get_hash_hex_algop (
      hex=0x555555a11180 "b2f0a7f47f5f2aebe1e7fceff19a57de20a78c06 refs/heads/master", hash=0x7fffffffdc00 "$h\240UUU",
      algop=0x0) at hex.c:11
  #1  0x000055555573a9aa in get_oid_hex_algop (
      hex=0x555555a11180 "b2f0a7f47f5f2aebe1e7fceff19a57de20a78c06 refs/heads/master", oid=0x7fffffffdc00, algop=0x0)
      at hex.c:29
  #2  0x000055555573aad1 in parse_oid_hex_algop (
      hex=0x555555a11180 "b2f0a7f47f5f2aebe1e7fceff19a57de20a78c06 refs/heads/master", oid=0x7fffffffdc00,
      end=0x7fffffffdc28, algop=0x0) at hex.c:62
  #3  0x00005555556acaf3 in read_bundle_header_fd (fd=3, header=0x7fffffffddf0, report_path=0x555555a110a0 "foo")
      at bundle.c:121
  #4  0x00005555556accdf in read_bundle_header (path=0x555555a110a0 "foo", header=0x7fffffffddf0) at bundle.c:153
  #5  0x000055555558c8d6 in open_bundle (path=0x555555a110a0 "foo", header=0x7fffffffddf0, name=0x0)
      at builtin/bundle.c:123
  #6  0x000055555558cd8b in cmd_bundle_unbundle (argc=1, argv=0x7fffffffe4b0, prefix=0x0) at builtin/bundle.c:210
  #7  0x000055555558cff1 in cmd_bundle (argc=2, argv=0x7fffffffe4b0, prefix=0x0) at builtin/bundle.c:244
Curiously, the next line after the open_bundle() call is:
          if (!startup_info->have_repository)
                  die(_("Need a repository to unbundle."));

So one option is to just do that check earlier. But that leaves other sub-commands of "git bundle":

  - "create" likewise requires a repo, and seems OK. That makes sense
    since we're not reading anything.
  - "verify" requires a repo, which I wouldn't have expected, but I
    guess it's because we probably unbundle under the hood to walk.
    Anyway, it gets the ordering right here and checks the repo before
    opening the bundle.
  - list-heads doesn't require a repo, and segfaults. So it really does
    need some kind of detection or default to know which hash to use.
-Peff
Previous: ArcticLampyridNext: Junio C Hamano
Message 2 of 10 in “SIGSEGV Error Occurs When Attempting to Unbundle Without Initializing Git Repository.”
  1. ArcticLampyridAug 12, 2024
  2. Jeff KingAug 12, 2024
  3. Junio C HamanoAug 12, 2024
  4. brian m. carlsonAug 12, 2024
  5. 0/2 bundle: fix handling of object formatPatrick Steinhardt, Aug 13, 2024
  6. 1/2 builtin/bundle: have unbundle check for repo before opening its bundlePatrick Steinhardt, Aug 13, 2024
  7. Eric SunshineAug 13, 2024
  8. 2/2 bundle: default to SHA1 when reading bundle headersPatrick Steinhardt, Aug 13, 2024
  9. Jeff KingAug 13, 2024
  10. Junio C HamanoAug 13, 2024

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.