<< Previous | Next >>

Maemo development is mostly done in C

So one indispensable tool is valgrind. However, even the simplest maemo application trips valgrind warnings and leaks. For valgrind to become totally useful again, we need to get rid of those.

The warnings are all about Xlib not nulling out unused protocol bytes, and just transmitting the the random memory that is there. Basically this is totally harmless and a optimization deliberately in X.

The leaks are mostly glib and gtk initializations, there is no un-initialization. (However, the leaks are real and should ideally be fixed one day.)

To work around these, you can use valgrind with --gen-suppressions=yes. And the output of this you can add to /usr/lib/valgrind/default.supp. (But as you are lazy, you copy paste the stuff below to that file.)

Now you can focus on just your own applications badness.

Extremely useful is run-standalone.sh valgrind --db-attach=yes ./your-app. It will ask you on every potential error found if you want to attach the gdb. If you do, you can inspect the variables and state leading up to the error.

But I guess I won't have to explain debugging to any of you ... so here is the stuff you should append default.supp with. A last issue, though, is the debugging symbols (-dbg packages); the more you have installed the more valgrind can be specific about the backtraces, and the better it can match those suppressions, but it might also start skipping suppressions.

# maemo specific issues
{
   X using uninizialized memory
   Memcheck:Param
   write(buf)
   fun:write
   fun:_X11TransWrite
   obj:*/lib/libX11.so.*
}
{
   X using uninizialized memory
   Memcheck:Param
   writev(vector[...])
   fun:do_writev
   obj:*/lib/libX11.so.*
   fun:_X11TransWritev
   obj:*/lib/libX11.so.*
}
{
   X using uninizialized memory
   Memcheck:Addr4
   obj:*/lib/libX11.so.*
   fun:XGetAtomName
   fun:gdk_x11_xatom_to_atom_for_display
}
{
   glib-baddness
   Memcheck:Leak
   fun:*calloc
   fun:g_malloc0
   obj:*/lib/libglib-2.0.so.*
   fun:g_slice_alloc
   fun:g_hash_table_new_full
   fun:g_hash_table_new
   fun:g_quark_from_static_string
   fun:g_type_init_with_debug_flags
   fun:g_type_init
}
{
   glib-baddness
   Memcheck:Leak
   fun:*malloc
   fun:*realloc
   fun:g_realloc
   fun:g_quark_from_static_string
   fun:g_type_init_with_debug_flags
   fun:g_type_init
}
{
   glib-baddness
   Memcheck:Leak
   fun:*malloc
   fun:g_malloc
   fun:g_slice_alloc
   fun:g_hash_table_new_full
   fun:g_hash_table_new
   fun:g_quark_from_static_string
   fun:g_type_init_with_debug_flags
   fun:g_type_init
}
{
   glib-baddness
   Memcheck:Leak
   fun:*realloc
   fun:g_realloc
   fun:g_boxed_type_register_static
   fun:g_value_array_get_type
   obj:*/lib/libgobject-2.0.so.*
   fun:g_type_init_with_debug_flags
   fun:g_type_init
}
{
   glib-baddness
   Memcheck:Leak
   fun:*calloc
   fun:g_malloc0
   obj:*/lib/libgobject-2.0.so.*
   obj:*/lib/libgobject-2.0.so.*
   fun:g_type_init_with_debug_flags
   fun:g_type_init
}
{
   fonts leak
   Memcheck:Leak
   fun:*realloc
   obj:*/lib/libfontconfig.so.*
   obj:*/lib/libfontconfig.so.*
   obj:*/lib/libfontconfig.so.*
   fun:FcFontRenderPrepare
   obj:*/lib/libpangoft2-1.0.so.*
   obj:*/lib/libpangoft2-1.0.so.*
   obj:*/lib/libpango-1.0.so.*
   fun:pango_itemize_with_base_dir
   obj:*/lib/libpango-1.0.so.*
   obj:*/lib/libpango-1.0.so.*
   obj:*/lib/libgtk-x11-2.0.so.*
}

Or download my current default.supp file: default.supp wich should go here: /usr/lib/valgrind/default.supp

Last modified: 2007-11-19 20:17 GMT