Bug 1204191 - infinite loop in "git ls-tree" for broken symlink under refs/heads
Summary: infinite loop in "git ls-tree" for broken symlink under refs/heads
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Software Collections
Classification: Red Hat
Component: git
Version: rh-git29
Hardware: Unspecified
OS: Unspecified
urgent
high
Target Milestone: rc
: 2.3
Assignee: Petr Stodulka
QA Contact: Leos Pol
URL:
Whiteboard:
Depends On:
Blocks: 1204193 1414792
TreeView+ depends on / blocked
 
Reported: 2015-03-20 14:51 UTC by Frank Ch. Eigler
Modified: 2017-01-19 13:01 UTC (History)
6 users (show)

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:
Clone Of:
: 1204193 (view as bug list)
Environment:
Last Closed: 2016-11-15 10:04:16 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2016:2728 0 normal SHIPPED_LIVE new packages: rh-git29 2016-11-15 14:37:48 UTC

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


Note You need to log in before you can comment on or make changes to this bug.