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:244Curiously, 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