3

I tried to compile the first example of libwnck's introduction:

#include <libwnck/libwnck.h>
int main (int argc, char **argv)
{
    WnckScreen *screen;
    WnckWindow *active_window;
    GList *window_l;

    gdk_init (&argc, &argv);
    screen = wnck_screen_get_default ();
    wnck_screen_force_update (screen);
    active_window = wnck_screen_get_active_window (screen);
    for (window_l = wnck_screen_get_windows (screen); window_l != NULL; window_l = window_l->next)
    {
        WnckWindow *window = WNCK_WINDOW (window_l->data);
        g_print ("%s%s\n", wnck_window_get_name (window),
                window == active_window ? " (active)" : "");
    }
    wnck_shutdown();
}

with this command line:

gcc -o testwnck testwnck.cpp -DWNCK_I_KNOW_THIS_IS_UNSTABLE `pkg-config --libs libwnck-3.0` `pkg-config --cflags libwnck-3.0`

but when I run it through valgrind, many errors appear. For instance:

==20365== 96 bytes in 2 blocks are possibly lost in loss record 876 of 1,019
==20365==    at 0x4C28F40: malloc (vg_replace_malloc.c:296)
==20365==    by 0x6F6E0A0: g_malloc (in /usr/lib64/libglib-2.0.so.0.4200.0)
==20365==    by 0x6F84BB5: g_memdup (in /usr/lib64/libglib-2.0.so.0.4200.0)
==20365==    by 0x6CFD364: type_iface_vtable_base_init_Wm (in /usr/lib64/libgobject-2.0.so.0.4200.0)
==20365==    by 0x6CFE5BC: g_type_class_ref (in /usr/lib64/libgobject-2.0.so.0.4200.0)
==20365==    by 0x6CE79D4: g_object_new_valist (in /usr/lib64/libgobject-2.0.so.0.4200.0)
==20365==    by 0x6CE7BD3: g_object_new (in /usr/lib64/libgobject-2.0.so.0.4200.0)
==20365==    by 0x6745E6B: gdk_pixbuf_new_from_data (in /usr/lib64/libgdk_pixbuf-2.0.so.0.3000.8)
==20365==    by 0x4E60681: scaled_from_pixdata (in /usr/lib64/libwnck-3.so.0.2.2)
==20365==    by 0x4E62DE7: _wnck_read_icons (in /usr/lib64/libwnck-3.so.0.2.2)
==20365==    by 0x4E57F74: get_icons (in /usr/lib64/libwnck-3.so.0.2.2)
==20365==    by 0x4E58DC6: force_update_now (in /usr/lib64/libwnck-3.so.0.2.2)

Adding a call to wnck_shutdown() just before returning from the main function does not help. What can I do to suppress these errors?

EDIT: I have also tried using gtk suppression file from valgrind, but I still have errors.

JohnH
  • 2,713
  • 12
  • 21
qdii
  • 12,505
  • 10
  • 59
  • 116
  • Is that the entire output from valgrind? If you can post all the parts that output in red (:=######==) that would be helpful. If there are outputs in between the valgrind parts, that should not be required. – R Schultz Dec 06 '14 at 22:25
  • @RSchultz complete log can be seen here: https://bpaste.net/show/74ef88d97ba8 – qdii Dec 06 '14 at 22:30
  • Did you try it with the stable version of libwnck? – R Schultz Dec 06 '14 at 22:44
  • When stacks get this deep, I add `--num-callers=50` to valgrind's options to get deeper info out of the origin of the leak. You will also want to compile your code with `-g` to add full debugging symbols to get line numbers from your modules where the stacks originate from. – JohnH Dec 11 '14 at 21:35

1 Answers1

0

If the leak is still reported when using the latest GLib suppression file, then please file a bug against libwnck as it’s likely a leak in libwnck itself.

However, I suspect that the allocation you’re seeing is one of the type class allocations which GObject does once per new class instance, which are deliberately never freed (they essentially form part of the runtime). But that’s fine because they are only ever done once, when a type is first used. The suppression file should suppress them.

Philip Withnall
  • 5,293
  • 14
  • 28