Debug Psi on Linux

From PsiWiki

If you are experiencing unusual crashes (segfaults) with Psi on Linux, this article can help you (and the devs) debug the problem.

Core Files

A Core file is a file containing the memory image of a particular process (in our case Psi). It is generated by the OS whenever a process crashes, if this functionality is enabled.

Setup

One way to enable core files is running

ulimit -c unlimited

This command can be added to /etc/profile to be run on each profile load.

More info on setting up the resource limits (which includes the size of the core files) can be found in

man limits

Check if the psi executable is very big (mine is 27MB). If it's that big, it has debug symbols included. A stripped Psi binary (with no debug symbols) has somewhere below 5MB.

Make sure you start the binary with debug symbols included. I've installed the 27MB binary instead of the default Psi binary (/usr/bin/psi for my distribution).

If Psi crashes with a segfault, a core file will be created. The core file will normally be named "core" or "core.$PID" and will be located in the directory from which you started Psi (usually $HOME). The names and locations of core files can be configured through the proc filesystem by the files /proc/sys/kernel/core_pattern and /proc/sys/kernel/core_uses_pid (see the proc manpage).

Debugging

You can view the call stack and even local variables using GDB and this core file.

Start GDB with:

gdb --core=corefilename /usr/bin/psi

At the GDB prompt, type

bt full

to get the call stack and the values of the local variables.

Copy what's printed on the screen and report to the devs, on the maillist.


Thanks for the help on improving Psi.