Skip to content

gitscanner_log Freezes When 'git log' Outputs to STDERR #5720

@jochenhz

Description

@jochenhz

Describe the bug
The scanner defined in gitscanner_log.go freezes on s.r.ReadString if git log receives an error through stderr. This only happens on Windows and cannot be reproduced on macOS. I've tried to come up with a fix myself, but I am puzzled why this is happening, as I am not that familiar with go. My guess is that the stderr buffer of cmd is running full but I am not sure.

To Reproduce
Took me quite some time to come up with a 100% reproduction. I have created a shell script that creates a test repo on GitHub using the CLI and that creates a corrupted .gitattributes file so that an error is printed on git log. So far, we had 2 different users stumbling upon and reporting this issue, so I guess it might happen quite often. In essence, the script is doing the following:

  1. Create a repo on GH and clone it
  2. Create a .dat file and track it with LFS
  3. Append many bad lines to the .gitattributes (to provoke a long stderr)
  4. Push to GitHub
  5. Invoke prune with some config (see attached shell script) and observe a freeze on Windows

See (and maybe run) attached issue.sh. Note: The script requires gh cli and will create and delete a test repository on your GitHub account.

Expected behavior
The script should not freeze, but print "prune done". Of course, this is user error due to a corrupted .gitattributes file being committed, but git LFS should not break because of this. Also, I guess there might be other scenarios where errors are printed on git log causing logscanner to freeze in LFS.

System environment
Windows 11

Output of git lfs env

git-lfs/3.4.1 (GitHub; windows amd64; go 1.20.11; git 0898dcbc)
git version 2.44.0.windows.1

LocalWorkingDir=
LocalGitDir=
LocalGitStorageDir=
LocalMediaDir=lfs\objects
LocalReferenceDirs=
TempDir=lfs\tmp
ConcurrentTransfers=8
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic,lfs-standalone-file,ssh
UploadTransfers=basic,lfs-standalone-file,ssh
GIT_EXEC_PATH=C:/Program Files/Git/mingw64/libexec/git-core
git config filter.lfs.process = "git-lfs filter-process"
git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions