Re: [gitg] Help with debugging a segfault in gitg



On Sun, May 21, 2017 at 4:01 PM, Wojciech Kozlowski <wojciech kozlowski vivaldi net> wrote:
I was recently trying out gitg and I've been enjoying it so far. I have recently hit a seg-fault in libgitg-1.0 that I can consistently reproduce. I'm a C/C++ developer so I figured I might try and debug and solve it myself since I've been wanting to contribute to an open-source project for quite a while and this is a perfect learning opportunity. I've set up the build environment and have compiled it, but at this point I'm at a loss as to what debugging tools you would use now for gitg. I don't even know where the logs go. Can anyone point me in the right direction in terms of what are the best resources for debugging? I have never worked on a Gnome or GTK project before so if there's a common place for these things in these projects, I don't know of it. The version on which I hit the seg-fault is 3.23.0 (Debian 9 repository version). I've checked out this version in the gitg repo. I can't compile the newest version to see if I could reproduce the bug there as it requires libgit2 and libgit2-glib to be >0.25 which is not available on Debian (it has 0.24) and I haven't yet gotten around to setting an environment with the newer versions.

Wojtek,

yes - this sounds like a great opportunity to contribute and learn.  :)

You're right that you'll first want to see whether the segfault still occurs in gitg master.  It looks like even Debian unstable still doesn't have libgit2-glib version 0.25.0:

https://packages.debian.org/search?keywords=libgit2-glib&searchon=names&suite=all&section=all

So yes, you'll need to build libgit2 and libgit2-glib yourself.  Fortunately that's easy.  I'm on Ubuntu 17.04  which is pretty similar to Debian, and this worked for me:

$ sudo apt build-dep libgit2
$ sudo apt build-dep libgit2-glib
$ git clone -b v0.25.0 https://github.com/libgit2/libgit2.git
$ cd libgit2
$ cmake .
$ make
$ sudo make install
$ cd ..
$ git clone -b v0.25.0 git://git.gnome.org/libgit2-glib
$ cd libgit2-glib
$ ./autogen.sh
$ sudo make install

Don't install version 0.25.1 (or master) of libgit2 - it has an incompatible change that will prevent libgit2-glib from building.

(Warning: libgit2 (like many cmake-based projects) has no 'make uninstall'!  But fortunately it's not to achieve that yourself, by finding all the files under /usr/local with 'git2' in their name and removing them.)

Once those libraries are installed, you should be able to build and run gitg from master.  If the segfault still occurs, it's time to debug.  I don't think gitg writes to a log file or does any conditonal logging via g_debug or similar functions.  So if you want to see what's going on as it runs, you'll just have to add printf statements to the code.

gdb is your friend.  You might also try Nemiver (https://wiki.gnome.org/Apps/Nemiver), with which I've had some success at times.

I hope this is enough to get started.  If you have more questions, feel free to ask again here or at newcomers-list gnome org.  good luck -

adam




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]