Skip to content

Infinite loop in mingw_rename if rename fails #1299

@WesleySSmith

Description

@WesleySSmith
  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.14.1.windows.1.1017.gb5915c6ae8.MSVC
built from commit: b5915c6ae881518927b9fa0b3c4df4d3edd37f23
sizeof-long: 4
machine: unknown
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 6.1.7601]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Path Option: Cmd
SSH Option: OpenSSH
CURL Option: WinSSL
CRLF Option: CRLFCommitAsIs
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled

  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

** insert your response here **

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

CMD, PowerShell, Jenkins

git init D:\XXX\workspace
git fetch --no-tags --progress https://XXX/_git/PAPI +refs/heads/*:refs/remotes/origin/* --depth=20
git fetch --no-tags --progress https://XXX/_git/PAPI +refs/heads/*:refs/remotes/origin/* --depth=20
git fetch --no-tags --progress https://XXX/_git/PAPI +refs/heads/*:refs/remotes/origin/* --depth=20
  • What did you expect to occur after running these commands?

3 successful fetches

  • What actually happened instead?

Third fetch hangs

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

Private repo, so can't post.

Process Explorer shows that the git that's hanging is not the one launched. Instead:
git.exe -> git.exe -> git.exe -> git-remote-https.exe -> git.exe -> git.exe,
The last git.exe in the chain is the one that's hanging - it takes 100% of the CPU and never exits. Its command line is:

git --shallow-file D:/XXX/workspace/.git/shallow.lock index-pack --stdin -v --fix-thin "--keep=fetch-pack 6676 on XXXBLD03" --pack_header=2,3425

I've compiled a debug version of git and have looked at the hang. There's an infinite loop in mingw_rename:

On line 2411, MoveFileExW fails
On line 2414, gle = 5 (ACCESS_DENIED)
On line 2418, SetFileAttributesW is called as expected
On line 2420 the "if" is false, so the function doesn't return on line 2422
On line 2425 condition is true, so if block is evaluated
On line 2435, the condition is true so the if block is evaluated
On line 2437, the goto repeat; command runs, which starts the loop again from line 2410.

So, it appears that if the rename fails, the code tries to fix up the file attributes and tries again, but if that's not the problem, then there's an infinite loop.

As to why exactly this rename is failing, it seems that a file is being renamed from .git/objects/pack/tmp_pack_96bdnb to .git/objects/pack/pack-ae983dc9c8057f4d5d2c8cdc3485cb6badde864b.pack, but a file with the destination name already exists.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions