Crossfire debugging tips

This page contains some tips for debugging.

Valgrind

Valgrind is a tool to find memory related errors, for example reading a variable before initializing it, reading or writing non-allocated memory, memory leaks, and so on.

However, due to the cfpython plugin, valgrind output tends to get filled up by a lot of python related valgrind errors. These are false positives (or at least nothing related to us). There is a solution: valgrind got a feature called suppression file. It lists errors valgrind should ignore. Here is an example of such a file, this works on my system, you will likely need to customize it, for your python system, and for changing lib64 to lib unless you are on a 64-bit platform.

{
   Python cond
   Memcheck:Cond
   obj:/usr/lib64/libpython2.4.so.1.0
}

{
   Python value 8
   Memcheck:Value8
   obj:/usr/lib64/libpython2.4.so.1.0
}
{
   Python invalid read 4
   Memcheck:Addr4
   obj:/usr/lib64/libpython2.4.so.1.0
}
{
   Python mem leak
   Memcheck:Leak
   obj:/usr/lib64/libpython2.4.so.1.0
}

Then run valgrind something like this:

valgrind --suppressions=path/to/suppressions-file --leak-check=full ./crossfire-server

This will ignore errors that are not interesting for crossfire developers.