Debugging cgit

For my git repositories I use cgit as the web frontend. The package I used had a problem displaying the treeview. Looking at /var/log/messages I saw that it segfaults. I’ve already fixed a segfault in cgit some time ago. I wondered how I was able to get gdb attached to it. It took me some time to figure it out so this is the way to document it for the future. Maybe someone else will find this useful.

The command to display the html on the commandline is:

CGIT_CONFIG="/srv/www/vhosts/libssh/cgitrc" /srv/www/cgi-bin/cgit/cgit.cgi 1>cgit.html 2>cgit.log

This will write the html output to cgit.html and the errors to cgit.log. So if you want to display a tree of the project, the url to it would be for example: http://git.libssh.org/projects/libssh.git/

So on the commandline this is:

QUERY_STRING="url=projects/libssh.git" CGIT_CONFIG="/srv/www/vhosts/libssh/cgitrc" /srv/www/cgi-bin/cgit/cgit.cgi 1>cgit.html 2>cgit.log

and if you need gdb to get a segfault you can simply use:

QUERY_STRING="url=projects/libssh.git/tree" CGIT_CONFIG="/path/to/libssh/cgitrc" gdb /srv/www/cgi-bin/cgit/cgit.cgi

It segfaulted cause the current version doesn’t support git 1.7.6 and a NULL pointer was passed to a function instead of the right values.

You may also like...

3 Responses

  1. Ferry says:

    So we can expect a patch for cgit, fixing the segfault?

  2. I’ve sent the patch upstream

    http://hjemli.net/pipermail/cgit/2011-August/000295.html

    The last two hunks fix the segfault …

  3. Thanks for this, it’s really useful information!

    Another thing that tripped me up when starting with CGit is the caching. If you’re developing a filter, CGit’s caching makes it appear that changes in the filter aren’t having an effect, when the problem is that CGit is rendering from its cache and not calling the filter at all.

    I worked around this by running `sudo rm -R /var/cache/git` each time I ran CGit to test the filter I was working on.

Leave a Reply

Your email address will not be published. Required fields are marked *