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

Re: [BUG REPORT] git fetch --prefetch with incorrect options hangs with 2.47.0

From
Jeff King <peff@peff.net>
Date
Nov 12, 2024, 06:49 UTC
Message-ID
<20241112064951.GA619985@coredump.intra.peff.net>
In-Reply-To
<SA1PR17MB6501281EF202EA694CF9DC03CA582@SA1PR17MB6501.namprd17.prod.outlook.com>
On Mon, Nov 11, 2024 at 10:15:44PM +0000, Eric Mills wrote:
Show 15 quoted lines
> What did you do before the bug happened? (Steps to reproduce your issue)
> I ran `git fetch --prefetch origin main` with git 2.47 on both my
> Windows machine (2.47.windows.2) and my Mac (2.47.0) and it hangs.
> 
> When I downgrade, same command succeeds on
> 2.46.2.Windows.1 / 2.46.2 (macOS).
> [...]
> On Windows, I don't get an error. It hangs indefinitely.
> On macOS, after a few seconds I got the following:
> 
> git(84051,0x20171cf40) malloc: *** error for object 0x600001978390:
> pointer being freed was not allocated
> 
> git(84051,0x20171cf40) malloc: *** set a breakpoint in
> malloc_error_break to debug

Thanks for the report. I see similar heap corruption problems on Linux. Building with ASan shows a double-free:

  ==646934==ERROR: AddressSanitizer: attempting double-free on 0x502000002450 in thread T0:
      #0 0x7f9ab1cf3918 in free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:52
      #1 0x557a1d8082c2 in refspec_clear /home/peff/compile/git/refspec.c:228
      #2 0x557a1ce92a08 in fetch_one builtin/fetch.c:2136
      #3 0x557a1ce9889d in cmd_fetch builtin/fetch.c:2443
      #4 0x557a1cd2e1ca in run_builtin /home/peff/compile/git/git.c:483
      #5 0x557a1cd2f2d8 in handle_builtin /home/peff/compile/git/git.c:749
      #6 0x557a1cd2fb3a in run_argv /home/peff/compile/git/git.c:819
      #7 0x557a1cd30e66 in cmd_main /home/peff/compile/git/git.c:954
      #8 0x557a1d1370c1 in main /home/peff/compile/git/common-main.c:64
      #9 0x7f9ab1233d67 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
      #10 0x7f9ab1233e24 in __libc_start_main_impl ../csu/libc-start.c:360
      #11 0x557a1cd27290 in _start (/home/peff/compile/git/git+0x129d290) (BuildId: cca88fc4d05f503e4aecc54e9437a56865d5eca1)
Bisecting on:
  make SANITIZE=address &&
  bin-wrappers/git fetch --prefetch origin master

turns up my ea4780307c (fetch: free "raw" string when shrinking refspec, 2024-09-24). I'll see if I can figure out what's going on.

-Peff
Previous: Eric MillsNext: Jeff King
Message 2 of 7 in “[BUG REPORT] git fetch --prefetch with incorrect options hangs with 2.47.0”
  1. Eric MillsNov 11, 2024
  2. Jeff KingNov 12, 2024
  3. 0/3 double-free with git fetch --prefetchJeff King, Nov 12, 2024
  4. 1/3 fetch: adjust refspec->raw_nr when filtering prefetch refspecsJeff King, Nov 12, 2024
  5. 2/3 refspec: drop separate raw_nr countJeff King, Nov 12, 2024
  6. 3/3 refspec: store raw refspecs inside refspec_itemJeff King, Nov 12, 2024
  7. Junio C HamanoNov 12, 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.