Repository navigation
Description
git hash-object hangs if git-lfs is installed, the path being hashed is managed by git-lfs, and the input is short.
I encountered this problem when running git clang-format --diff on a commit which modified some files that are managed by git-lfs. Some of the files were very short, and git clang-format got stuck. git clang-format --diff uses git hash-object --stdin internally.
Example:
.gitattributes:
stuck filter=lfs diff=lfs merge=lfs -text
command:
echo test | git hash-object --path stuck --stdin <--- gets stuck
The minimum input size for which git hash-object does not get stuck seems to be 1025 bytes.
I have been able to reproduce this problem on RHEL 7.5 (custom git and git-lfs build) and Arch Linux (official build from the package manager).
> git --version
git version 2.23.0
> git lfs env
git-lfs/2.9.0 (GitHub; linux amd64; go 1.13.1)
git version 2.23.0
LocalWorkingDir=/home/user/repo
LocalGitDir=/home/user/repo/.git
LocalGitStorageDir=/home/user/repo/.git
LocalMediaDir=/home/user/repo/.git/lfs/objects
LocalReferenceDirs=
TempDir=/home/user/repo/.git/lfs/tmp
ConcurrentTransfers=3
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=/home/user/repo/.git/lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic,lfs-standalone-file
UploadTransfers=basic,lfs-standalone-file
GIT_EXEC_PATH=/usr/lib/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"
> export GIT_TRACE=1
> echo test | git hash-object --path stuck --stdin
10:19:43.862623 git.c:440 trace: built-in: git hash-object --path stuck --stdin
10:19:43.862821 run-command.c:663 trace: run_command: 'git-lfs filter-process'
10:19:43.939865 trace git-lfs: exec: git 'version'
10:19:43.942695 trace git-lfs: exec: git 'config' '-l'
10:19:43.943958 trace git-lfs: Install hook: pre-push, force=false, path=/home/user/repo/.git/hooks/pre-push, upgrading...
10:19:43.965126 trace git-lfs: Install hook: post-checkout, force=false, path=/home/user/repo/.git/hooks/post-checkout, upgrading...
10:19:43.965230 trace git-lfs: Install hook: post-commit, force=false, path=/home/user/repo/.git/hooks/post-commit, upgrading...
10:19:43.965310 trace git-lfs: Install hook: post-merge, force=false, path=/home/user/repo/.git/hooks/post-merge, upgrading...
10:19:43.965389 trace git-lfs: Initialize filter-process
10:19:43.965498 trace git-lfs: exec: git '-c' 'filter.lfs.smudge=' '-c' 'filter.lfs.clean=' '-c' 'filter.lfs.process=' '-c' 'filter.lfs.required=false' 'rev-parse' 'HEAD' '--symbolic-full-name' 'HEAD'
10:19:43.967968 trace git-lfs: tq: running as batched queue, batch size of 100
<stuck here>
`-strace,2276 -f -ttt bash -c echo test | git hash-object --path stuck --stdin
`-bash,2279 -c echo test | git hash-object --path stuck --stdin
`-git,2281 hash-object --path stuck --stdin
`-git-lfs,2282 filter-process
|-{git-lfs},2283
|-{git-lfs},2284
|-{git-lfs},2285
|-{git-lfs},2286
|-{git-lfs},2287
|-{git-lfs},2288
|-{git-lfs},2290
`-{git-lfs},2292
...
[pid 2288] 1572172021.054676 wait4(2295, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, {ru_utime={tv_sec=0, tv_usec=1000}, ru_stime={tv_sec=0, tv_usec=2000}, ...}) = 2295
[pid 2288] 1572172021.054758 mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7b647ba000
[pid 2288] 1572172021.054830 futex(0xc0000a59c8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid 2292] 1572172021.054848 <... futex resumed>) = 0
[pid 2288] 1572172021.054854 <... futex resumed>) = 1
[pid 2292] 1572172021.054861 epoll_pwait(4, <unfinished ...>
[pid 2288] 1572172021.054877 read(0, <unfinished ...>
[pid 2292] 1572172021.054889 <... epoll_pwait resumed>[], 128, 0, NULL, 0) = 0
[pid 2288] 1572172021.054902 <... read resumed>"0012command=clean\n0013pathname=s"..., 4096) = 54
[pid 2292] 1572172021.054916 futex(0xc0000a4bc8, FUTEX_WAKE_PRIVATE, 1) = 1
[pid 2288] 1572172021.054944 write(1, "0013status=success\n0000", 23 <unfinished ...>
[pid 2285] 1572172021.054959 <... futex resumed>) = 0
[pid 2292] 1572172021.054974 epoll_pwait(4, <unfinished ...>
[pid 2288] 1572172021.054985 <... write resumed>) = 23
[pid 2281] 1572172021.054995 <... read resumed>"0013", 4) = 4
[pid 2285] 1572172021.055007 epoll_pwait(4, <unfinished ...>
[pid 2292] 1572172021.055026 <... epoll_pwait resumed>[], 128, 0, NULL, 824636440640) = 0
[pid 2288] 1572172021.055035 newfstatat(AT_FDCWD, "stuck", <unfinished ...>
[pid 2285] 1572172021.055046 <... epoll_pwait resumed>[], 128, 0, NULL, 0) = 0
[pid 2281] 1572172021.055053 read(5, <unfinished ...>
[pid 2292] 1572172021.055066 epoll_pwait(4, <unfinished ...>
[pid 2288] 1572172021.055074 <... newfstatat resumed>{st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
[pid 2285] 1572172021.055086 futex(0xc0000a4848, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid 2281] 1572172021.055099 <... read resumed>"status=success\n", 15) = 15
[pid 2292] 1572172021.055120 <... epoll_pwait resumed>[], 128, 0, NULL, 824635787008) = 0
[pid 2288] 1572172021.055131 umask(022 <unfinished ...>
[pid 2285] 1572172021.055145 <... futex resumed>) = 1
[pid 2284] 1572172021.055154 <... futex resumed>) = 0
[pid 2281] 1572172021.055164 read(5, <unfinished ...>
[pid 2292] 1572172021.055195 epoll_pwait(4, <unfinished ...>
[pid 2288] 1572172021.055208 <... umask resumed>) = 022
[pid 2285] 1572172021.055215 futex(0xc0000a4bc8, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 2284] 1572172021.055227 futex(0xc0000a4848, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 2281] 1572172021.055239 <... read resumed>"0000", 4) = 4
[pid 2288] 1572172021.055252 newfstatat(AT_FDCWD, "/home/user/repo/.git/lfs/tmp", <unfinished ...>
[pid 2281] 1572172021.055264 read(5, <unfinished ...>
[pid 2288] 1572172021.055274 <... newfstatat resumed>{st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
[pid 2288] 1572172021.055290 umask(022) = 022
[pid 2288] 1572172021.055319 getpid() = 2282
[pid 2288] 1572172021.055351 openat(AT_FDCWD, "/home/user/repo/.git/lfs/tmp/180773060", O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0600) = 3
[pid 2288] 1572172021.055417 epoll_ctl(4, EPOLL_CTL_ADD, 3, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=1694760408, u64=140167952465368}}) = -1 EPERM (Operation not permitted)
[pid 2288] 1572172021.055452 epoll_ctl(4, EPOLL_CTL_DEL, 3, 0xc00022b1fc) = -1 EPERM (Operation not permitted)
[pid 2288] 1572172021.055484 fchmodat(AT_FDCWD, "/home/user/repo/.git/lfs/tmp/180773060", 0644) = 0
[pid 2288] 1572172021.055565 write(3, "test\n", 5) = 5
[pid 2288] 1572172021.055604 read(0, <unfinished ...>
[pid 2283] 1572172021.057447 <... nanosleep resumed>NULL) = 0
[pid 2283] 1572172021.057463 nanosleep({tv_sec=0, tv_nsec=10000000}, NULL) = 0
[pid 2283] 1572172021.067558 nanosleep({tv_sec=0, tv_nsec=20000}, NULL) = 0
[pid 2283] 1572172021.067660 futex(0x55cbc161cab0, FUTEX_WAIT_PRIVATE, 0, {tv_sec=60, tv_nsec=0}
... <FUTEX_WAIT_PRIVATE fails with ETIMEDOUT, repeats indefinitely
Activity
bk2204 commentedon Oct 28, 2019
Hey,
Thanks for reporting this. I can confirm it, and it looks like it's a problem with the filter process portion because
echo test | git -c filter.lfs.process= hash-object --path foo.bin --stdindoesn't fail for me. You may be able to work around this by unsetting thefilter.lfs.processvariable, although that will result in generally less efficient operation.I'll mark this as a bug, and hopefully I'll get time to fix it soon.
rivuonna commentedon Nov 6, 2019
I tested the correction, and I can confirm that it fixes the issue. Thanks!
rivuonna commentedon Mar 10, 2020
The correction made it to v2.10.0: https://github.com/git-lfs/git-lfs/releases/tag/v2.10.0
I verified in Arch Linux that the issue is fixed in v2.10.0.
lfs,t: restore progress log in clean filter