Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1204191

Summary: infinite loop in "git ls-tree" for broken symlink under refs/heads
Product: Red Hat Software Collections Reporter: Frank Ch. Eigler <fche>
Component: gitAssignee: Petr Stodulka <pstodulk>
Status: CLOSED ERRATA QA Contact: Leos Pol <lpol>
Severity: high Docs Contact:
Priority: urgent    
Version: rh-git29CC: hhorak, jorton, kanderso, lpol, mbenitez, mkyral
Target Milestone: rc   
Target Release: 2.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rh-git29-git-2.9.3-2.el6 rh-git29-git-2.9.3-2.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1204193 (view as bug list) Environment:
Last Closed: 2016-11-15 10:04:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1204193, 1414792    

Description Frank Ch. Eigler 2015-03-20 14:51:04 UTC
A git19-git installation (being invoked via gitweb) goes into an infinite loop while serving pretty vanilla requests, if the refs/heads/ directory contains a symlink that's broken.

Reproduction recipe:

% git init
% mkdir .git/refs/remotes
% ln -s ../remotes/foo .git/refs/heads/bar
% strace git --git-dir=`pwd`.git ls-tree bar
[...]
open("/sourceware1/home/fche/tmp2/.git/refs/heads/bar", O_RDONLY) = -1 ENOENT (No such file or directory)
lstat("/sourceware1/home/fche/tmp2/.git/refs/heads/bar", {st_mode=S_IFLNK|0777, st_size=14, ...}) = 0
readlink("/sourceware1/home/fche/tmp2/.git/refs/heads/bar", "../remotes/foo", 255) = 14
open("/sourceware1/home/fche/tmp2/.git/refs/heads/bar", O_RDONLY) = -1 ENOENT (No such file or directory)
lstat("/sourceware1/home/fche/tmp2/.git/refs/heads/bar", {st_mode=S_IFLNK|0777, st_size=14, ...}) = 0
readlink("/sourceware1/home/fche/tmp2/.git/refs/heads/bar", "../remotes/foo", 255) = 14
[...endlessly looping...]


When gdb is sicced at it, the loop appears to be around line 1360..1401 of refs.c.

Comment 2 Petr Stodulka 2015-03-23 13:58:30 UTC
correction:
-> % strace git --git-dir=`pwd`.git ls-tree bar
% strace git --git-dir=`pwd`/.git ls-tree bar

or just
git ls-tree bar

Comment 6 Leos Pol 2016-10-12 12:11:28 UTC
I'm still able to replicate the issue with the latest build:
# rpm -q rh-git29-git
rh-git29-git-2.9.3-1.el7.x86_64
# cd /tmp
# git init testrepo
Initialized empty Git repository in /tmp/testrepo/.git/
# cd testrepo
# mkdir -p .git/refs/remotes
# ln -s ../remotes/foo .git/refs/heads/bar
# timeout 10 git ls-tree bar
# echo $?
124

Comment 7 Petr Stodulka 2016-10-14 13:36:42 UTC
Thanks for catch. Now it is fixed. Issue wasn't fixed maybe by mistake in upstream. I don't know why fix wasn't applied previously. So it is discussed in upstream now.

Comment 11 errata-xmlrpc 2016-11-15 10:04:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHEA-2016-2728.html