# Re: Re: CGIT 0.8.3.1 "chokes" on some bare repos

5 messages from 2010-08-03 to 2010-08-03. Participants: Lars Hjemli, Eugene Sajine.
Thread: https://gitlist.dev/t/24620

## Lars Hjemli, 2010-08-03 17:49

Subject: Re: Re: CGIT 0.8.3.1 "chokes" on some bare repos
Message-ID: <AANLkTinDPa7ngcTEfYC8k2O3hwkYszEUsb3pZqnuOSo2@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTinDPa7ngcTEfYC8k2O3hwkYszEUsb3pZqnuOSo2%40mail.gmail.com
In-Reply-To: <90e6ba53a8a0a88e46048cee6566@google.com>

```
On Tue, Aug 3, 2010 at 19:10,  <Euguess@gmail.com> wrote:
> The command you provided is not giving any error messages in one of the
> repositories which shows incorrectly.
>
> As for URL - unfortunately it cannot be done as all the code is on closed
> LAN

Ok. Try the following:

1) make sure caching is disabled in /etc/cgitrc (nocache=1)
2) find the repo.url setting for the troublesome repo in /etc/cgitrc
3) run `PATH_INFO=$BAD_REPO_URL /path/to/cgit.cgi 1>cgit.html 2>cgit.log`
4) check if cgit.html is ok - if so, your problem is probably due to
stale cache entries which could be caused by permission problems or
stale *.lock files in /var/cache/cgit
5) check cgit.log for any errormessage - if there's errors but they
don't make any sense to you, try repeating step 3 but run cgit under
either strace or gdb.
6) please report the results of this experiment ;)

--
larsh

```

## Eugene Sajine, 2010-08-03 18:19

Subject: Re: Re: CGIT 0.8.3.1 "chokes" on some bare repos
Message-ID: <AANLkTindiOoy-4W5DJ9AGa8q29Tsm9P8K_4TEgRfmJW=@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTindiOoy-4W5DJ9AGa8q29Tsm9P8K_4TEgRfmJW%3D%40mail.gmail.com
In-Reply-To: <AANLkTinDPa7ngcTEfYC8k2O3hwkYszEUsb3pZqnuOSo2@mail.gmail.com>

```
On Tue, Aug 3, 2010 at 1:49 PM, Lars Hjemli <hjemli@gmail.com> wrote:
> On Tue, Aug 3, 2010 at 19:10,  <Euguess@gmail.com> wrote:
>> The command you provided is not giving any error messages in one of the
>> repositories which shows incorrectly.
>>
>> As for URL - unfortunately it cannot be done as all the code is on closed
>> LAN
>
> Ok. Try the following:
>
> 1) make sure caching is disabled in /etc/cgitrc (nocache=1)
> 2) find the repo.url setting for the troublesome repo in /etc/cgitrc
> 3) run `PATH_INFO=$BAD_REPO_URL /path/to/cgit.cgi 1>cgit.html 2>cgit.log`
> 4) check if cgit.html is ok - if so, your problem is probably due to
> stale cache entries which could be caused by permission problems or
> stale *.lock files in /var/cache/cgit
> 5) check cgit.log for any errormessage - if there's errors but they
> don't make any sense to you, try repeating step 3 but run cgit under
> either strace or gdb.
> 6) please report the results of this experiment ;)
>
> --
> larsh
>

I have disabled cache: i have nocache=1 (we are working without cache
yet,  cache-size set to 0, but for the experiment i commented this
out)
We are using scan mode as we have central folder to store our repos.
So I switched off the scanmode by commenting the scan-url out from
cgitrc

Now when i'm trying to generate the html for the repo in question i
get html where it says "no repositories found". It is obviously not
picking up the PATH_INFO

The command is like this:
$ PATH_INFO=/home/users/gitrepouser/repos/subfolder/repo.git
./cgit.cgi 1>cgit.html 2>cgit.log

Usually, we are scanning the folder /home/users/gitrepouser/repos/
cgit.log is empty so far


Thanks,
Eugene

```

## Lars Hjemli, 2010-08-03 18:47

Subject: Re: Re: CGIT 0.8.3.1 "chokes" on some bare repos
Message-ID: <AANLkTin6+X=nTTqLG=xCYDSPKWX3CVPTxAhzDM9uKMW5@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTin6%2BX%3DnTTqLG%3DxCYDSPKWX3CVPTxAhzDM9uKMW5%40mail.gmail.com
In-Reply-To: <AANLkTindiOoy-4W5DJ9AGa8q29Tsm9P8K_4TEgRfmJW=@mail.gmail.com>

```
On Tue, Aug 3, 2010 at 20:19, Eugene Sajine <euguess@gmail.com> wrote:
> I have disabled cache: i have nocache=1 (we are working without cache
> yet,  cache-size set to 0, but for the experiment i commented this
> out)

Good

> We are using scan mode as we have central folder to store our repos.
> So I switched off the scanmode by commenting the scan-url out from
> cgitrc

Then you'll have to add the repo.* settings to cgitrc by hand, or else...

> Now when i'm trying to generate the html for the repo in question i
> get html where it says "no repositories found".

This is expected.


> The command is like this:
> $ PATH_INFO=/home/users/gitrepouser/repos/subfolder/repo.git
> ./cgit.cgi 1>cgit.html 2>cgit.log

Add this to your cgitrc:

repo.url=foo
repo.path=/home/users/gitrepouser/repos/subfolder/repo.git

Then run `PATH_INFO=foo ./cgit.cgi 1>cgit.html 2>cgit.log`

--
larsh

```

## Eugene Sajine, 2010-08-03 19:34

Subject: Re: Re: CGIT 0.8.3.1 "chokes" on some bare repos
Message-ID: <AANLkTi=Ho=ZiOpMszSEWTjY=PKg9AHp9wY-jxcd3H_jG@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3DHo%3DZiOpMszSEWTjY%3DPKg9AHp9wY-jxcd3H_jG%40mail.gmail.com
In-Reply-To: <AANLkTin6+X=nTTqLG=xCYDSPKWX3CVPTxAhzDM9uKMW5@mail.gmail.com>

```
On Tue, Aug 3, 2010 at 2:47 PM, Lars Hjemli <hjemli@gmail.com> wrote:
> On Tue, Aug 3, 2010 at 20:19, Eugene Sajine <euguess@gmail.com> wrote:
>> I have disabled cache: i have nocache=1 (we are working without cache
>> yet,  cache-size set to 0, but for the experiment i commented this
>> out)
>
> Good
>
>> We are using scan mode as we have central folder to store our repos.
>> So I switched off the scanmode by commenting the scan-url out from
>> cgitrc
>
> Then you'll have to add the repo.* settings to cgitrc by hand, or else...
>
>> Now when i'm trying to generate the html for the repo in question i
>> get html where it says "no repositories found".
>
> This is expected.
>
>
>> The command is like this:
>> $ PATH_INFO=/home/users/gitrepouser/repos/subfolder/repo.git
>> ./cgit.cgi 1>cgit.html 2>cgit.log
>
> Add this to your cgitrc:
>
> repo.url=foo
> repo.path=/home/users/gitrepouser/repos/subfolder/repo.git
>
> Then run `PATH_INFO=foo ./cgit.cgi 1>cgit.html 2>cgit.log`
>
> --
> larsh
>

Touchdown!;)

It segfaults:

GNU gdb Red Hat Linux (6.3.0.0-1.159.el4rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host
libthread_db library "/lib/tls/libthread_db.so.1".

Core was generated by `./cgit.cgi'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
Reading symbols from /lib/libcrypto.so.4...done.
Loaded symbols for /lib/libcrypto.so.4
Reading symbols from /lib/tls/libc.so.6...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /usr/lib/libgssapi_krb5.so.2...done.
Loaded symbols for /usr/lib/libgssapi_krb5.so.2
Reading symbols from /usr/lib/libkrb5.so.3...done.
Loaded symbols for /usr/lib/libkrb5.so.3
Reading symbols from /lib/libcom_err.so.2...done.
Loaded symbols for /lib/libcom_err.so.2
Reading symbols from /usr/lib/libk5crypto.so.3...done.
Loaded symbols for /usr/lib/libk5crypto.so.3
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0  0x080538fa in cmp_tag_age (a=0x8bcc760, b=0x8bcc764) at ui-refs.c:52
52      ui-refs.c: No such file or directory.
        in ui-refs.c
(gdb) where
#0  0x080538fa in cmp_tag_age (a=0x8bcc760, b=0x8bcc764) at ui-refs.c:52
#1  0x0040eb45 in msort_with_tmp () from /lib/tls/libc.so.6
#2  0x0040ea1d in msort_with_tmp () from /lib/tls/libc.so.6
#3  0x0040ea1d in msort_with_tmp () from /lib/tls/libc.so.6
#4  0x0040ea1d in msort_with_tmp () from /lib/tls/libc.so.6
#5  0x0040ea1d in msort_with_tmp () from /lib/tls/libc.so.6
#6  0x0040ecdc in qsort () from /lib/tls/libc.so.6
#7  0x08053f8b in cgit_print_tags (maxcount=10) at ui-refs.c:217
#8  0x08058189 in cgit_print_summary () at ui-summary.c:56
#9  0x0804da70 in summary_fn (ctx=0x80e44a0) at cmd.c:119
#10 0x0804cc6d in process_request (cbdata=0x80e44a0) at cgit.c:431
#11 0x0804ae31 in cache_process (size=0, path=0x80a2e24
"../cgit/cache", key=0x8ba6028 "foo", ttl=5, fn=0x804cb28
<process_request>, cbdata=0x80e44a0) at cache.c:322
#12 0x0804d81e in main (argc=1, argv=0xbfffa2b4) at cgit.c:712

Thanks,
Eugene

```

## Lars Hjemli, 2010-08-03 20:20

Subject: Re: Re: CGIT 0.8.3.1 "chokes" on some bare repos
Message-ID: <AANLkTimNyLBjVe+sWRJ+=eidazE-JP6Rshk1XzhrBCG3@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimNyLBjVe%2BsWRJ%2B%3DeidazE-JP6Rshk1XzhrBCG3%40mail.gmail.com
In-Reply-To: <AANLkTi=Ho=ZiOpMszSEWTjY=PKg9AHp9wY-jxcd3H_jG@mail.gmail.com>

```
On Tue, Aug 3, 2010 at 21:34, Eugene Sajine <euguess@gmail.com> wrote:
> It segfaults:
>
> #0  0x080538fa in cmp_tag_age (a=0x8bcc760, b=0x8bcc764) at ui-refs.c:52

Great, thanks for pinpointing the bug. Could you test if the following
patch fixes the problem? I've also attached it since gmail tend to
damage patches...

---snip---
From: Lars Hjemli <hjemli@gmail.com>
Date: Tue, 3 Aug 2010 22:06:21 +0200
Subject: [PATCH] ui-refs.c: avoid segfault on unparsed ref objects

When a ref refers to something other then a commit or tag object, cgit
could segfault when trying to display the ref info.

Noticed-by: Eugene Sajine <euguess@gmail.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
 ui-refs.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/ui-refs.c b/ui-refs.c
index d3b4f6e..6571cc4 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -42,23 +42,25 @@ static int cmp_branch_age(const void *a, const void *b)
 	return cmp_age(r1->commit->committer_date, r2->commit->committer_date);
 }

+static int get_ref_age(struct refinfo *ref)
+{
+	if (!ref->object)
+		return 0;
+	switch (ref->object->type) {
+	case OBJ_TAG:
+		return ref->tag ? ref->tag->tagger_date : 0;
+	case OBJ_COMMIT:
+		return ref->commit ? ref->commit->committer_date : 0;
+	}
+	return 0;
+}
+
 static int cmp_tag_age(const void *a, const void *b)
 {
 	struct refinfo *r1 = *(struct refinfo **)a;
 	struct refinfo *r2 = *(struct refinfo **)b;
-	int r1date, r2date;
-
-	if (r1->object->type != OBJ_COMMIT)
-		r1date = r1->tag->tagger_date;
-	else
-		r1date = r1->commit->committer_date;
-
-	if (r2->object->type != OBJ_COMMIT)
-		r2date = r2->tag->tagger_date;
-	else
-		r2date = r2->commit->committer_date;

-	return cmp_age(r1date, r2date);
+	return cmp_age(get_ref_age(r1), get_ref_age(r2));
 }

 static int print_branch(struct refinfo *ref)
-- 
1.7.1


From 3687be20bc4abf0c0c197d617afaa3a717b1ab9c Mon Sep 17 00:00:00 2001
From: Lars Hjemli <hjemli@gmail.com>
Date: Tue, 3 Aug 2010 22:06:21 +0200
Subject: [PATCH] ui-refs.c: avoid segfault on unparsed ref objects

When a ref refers to something other then a commit or tag object, cgit
could segfault when trying to display the ref info.

Noticed-by: Eugene Sajine <euguess@gmail.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
 ui-refs.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/ui-refs.c b/ui-refs.c
index d3b4f6e..6571cc4 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -42,23 +42,25 @@ static int cmp_branch_age(const void *a, const void *b)
 	return cmp_age(r1->commit->committer_date, r2->commit->committer_date);
 }
 
+static int get_ref_age(struct refinfo *ref)
+{
+	if (!ref->object)
+		return 0;
+	switch (ref->object->type) {
+	case OBJ_TAG:
+		return ref->tag ? ref->tag->tagger_date : 0;
+	case OBJ_COMMIT:
+		return ref->commit ? ref->commit->committer_date : 0;
+	}
+	return 0;
+}
+
 static int cmp_tag_age(const void *a, const void *b)
 {
 	struct refinfo *r1 = *(struct refinfo **)a;
 	struct refinfo *r2 = *(struct refinfo **)b;
-	int r1date, r2date;
-
-	if (r1->object->type != OBJ_COMMIT)
-		r1date = r1->tag->tagger_date;
-	else
-		r1date = r1->commit->committer_date;
-
-	if (r2->object->type != OBJ_COMMIT)
-		r2date = r2->tag->tagger_date;
-	else
-		r2date = r2->commit->committer_date;
 
-	return cmp_age(r1date, r2date);
+	return cmp_age(get_ref_age(r1), get_ref_age(r2));
 }
 
 static int print_branch(struct refinfo *ref)
-- 
1.7.1


```
