GLib: marshaling a{sv} where the v is ay?

John (J5) Palmieri johnp at redhat.com
Fri Sep 30 13:40:33 PDT 2005


On Thu, 2005-09-29 at 17:21 -0400, Colin Walters wrote:
> On Fri, 2005-09-23 at 17:06 -0400, John (J5) Palmieri wrote:
> +gboolean 
> +my_object_process_variant_of_array_of_ints123 (MyObject *obj, GValue
> *variant, GError **error)
> +{
> [...]
> +
> +  g_value_unset (variant);
> 
> That looks wrong to me; variant is an input parameter, you shouldn't
> free or unset it, that should be done by the method invocation code.
> 
> Does that actually not crash?  If so we probably have a memleak
> somewhere...valgrind should say.

Removing the unset:

==15074== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 33 from
2)
==15074== malloc/free: in use at exit: 40783 bytes in 635 blocks.
==15074== malloc/free: 1332 allocs, 697 frees, 330775 bytes allocated.
==15074== For counts of detected errors, rerun with: -v
==15074== searching for pointers to 635 not-freed blocks.
==15074== checked 150908 bytes.
==15074==
==15074== 16 bytes in 1 blocks are definitely lost in loss record 2 of
12
==15074==    at 0x1B901812: malloc (vg_replace_malloc.c:149)
==15074==    by 0x1B902B5D: realloc (vg_replace_malloc.c:306)
==15074==    by 0x1BA0351E: g_realloc
(in /usr/lib/libglib-2.0.so.0.800.1)
==15074==    by 0x1BA17132: (within /usr/lib/libglib-2.0.so.0.800.1)
==15074==    by 0x1BA171F7: g_string_sized_new
(in /usr/lib/libglib-2.0.so.0.800.1)
==15074==    by 0x1BA17C45: g_string_new
(in /usr/lib/libglib-2.0.so.0.800.1)
==15074==    by 0x1B917A47: lookup_or_register_specialized
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15074==    by 0x1B918167: _dbus_gtype_from_signature_iter
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15074==    by 0x1B918276: _dbus_gtype_from_signature
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15074==    by 0x1B91591B: demarshal_static_variant
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15074==    by 0x1B9159A5: demarshal_variant
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15074==    by 0x1B91587C: _dbus_gvalue_demarshal
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15074==
==15074==
==15074== 64 bytes in 1 blocks are definitely lost in loss record 3 of
12
==15074==    at 0x1B902BE0: realloc (vg_replace_malloc.c:306)
==15074==    by 0x1BA0351E: g_realloc
(in /usr/lib/libglib-2.0.so.0.800.1)
==15074==    by 0x1BA17132: (within /usr/lib/libglib-2.0.so.0.800.1)
==15074==    by 0x1BA1781C: g_string_insert_len
(in /usr/lib/libglib-2.0.so.0.800.1)
==15074==    by 0x1BA17CF2: g_string_append
(in /usr/lib/libglib-2.0.so.0.800.1)
==15074==    by 0x1B917ABA: lookup_or_register_specialized
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15074==    by 0x804A5A3: my_object_class_intern_init
(in /usr/src/johnp/dbus/test/glib/.libs/lt-test-service-glib)
==15074==    by 0x1B9BBDCF: g_type_class_ref
(in /usr/lib/libgobject-2.0.so.0.800.1)
==15074==    by 0x1B9A495E: g_object_newv
(in /usr/lib/libgobject-2.0.so.0.800.1)
==15074==    by 0x1B9A4D73: g_object_new_valist
(in /usr/lib/libgobject-2.0.so.0.800.1)
==15074==    by 0x1B9A4F1B: g_object_new
(in /usr/lib/libgobject-2.0.so.0.800.1)
==15074==    by 0x804B257: main
(in /usr/src/johnp/dbus/test/glib/.libs/lt-test-service-glib)
==15074==
==15074==
==15074== 70 (64 direct, 6 indirect) bytes in 1 blocks are definitely
lost in loss record 4 of 12
==15074==    at 0x1B901812: malloc (vg_replace_malloc.c:149)
==15074==    by 0x1BA0344F: g_malloc
(in /usr/lib/libglib-2.0.so.0.800.1)
==15074==    by 0x1BA240D3: g_io_channel_unix_new
(in /usr/lib/libglib-2.0.so.0.800.1)
==15074==    by 0x1B90BF16: connection_setup_add_watch
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15074==    by 0x1B90C1DC: add_watch
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15074==    by 0x1B954140: _dbus_watch_list_set_functions
(in /usr/src/johnp/dbus/dbus/.libs/libdbus-1.so.1.0.0)
==15074==    by 0x1B92F53B: dbus_connection_set_watch_functions
(in /usr/src/johnp/dbus/dbus/.libs/libdbus-1.so.1.0.0)
==15074==    by 0x1B90C4BE: dbus_connection_setup_with_g_main
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15074==    by 0x1B90C6D4: dbus_g_bus_get
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15074==    by 0x804B23A: main
(in /usr/src/johnp/dbus/test/glib/.libs/lt-test-service-glib)
==15074==
==15074==
==15074== 800 bytes in 20 blocks are possibly lost in loss record 5 of
12
==15074==    at 0x1B902AF4: calloc (vg_replace_malloc.c:279)
==15074==    by 0x1BA034BD: g_malloc0
(in /usr/lib/libglib-2.0.so.0.800.1)
==15074==    by 0x1B9B44BA: (within /usr/lib/libgobject-2.0.so.0.800.1)
==15074==    by 0x1B9B5FAA: (within /usr/lib/libgobject-2.0.so.0.800.1)
==15074==    by 0x1B9B61A3: g_type_init_with_debug_flags
(in /usr/lib/libgobject-2.0.so.0.800.1)
==15074==    by 0x1B9B6301: g_type_init
(in /usr/lib/libgobject-2.0.so.0.800.1)
==15074==    by 0x804B1BA: main
(in /usr/src/johnp/dbus/test/glib/.libs/lt-test-service-glib)
==15074==
==15074== LEAK SUMMARY:
==15074==    definitely lost: 144 bytes in 3 blocks.
==15074==    indirectly lost: 6 bytes in 1 blocks.
==15074==      possibly lost: 800 bytes in 20 blocks.
==15074==    still reachable: 39833 bytes in 611 blocks.
==15074==         suppressed: 0 bytes in 0 blocks.


Adding the unset back:

==15348== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 33 from
2)
==15348== malloc/free: in use at exit: 40783 bytes in 635 blocks.
==15348== malloc/free: 1332 allocs, 697 frees, 330775 bytes allocated.
==15348== For counts of detected errors, rerun with: -v
==15348== searching for pointers to 635 not-freed blocks.
==15348== checked 150908 bytes.
==15348==
==15348== 16 bytes in 1 blocks are definitely lost in loss record 2 of
12
==15348==    at 0x1B901812: malloc (vg_replace_malloc.c:149)
==15348==    by 0x1B902B5D: realloc (vg_replace_malloc.c:306)
==15348==    by 0x1BA0351E: g_realloc
(in /usr/lib/libglib-2.0.so.0.800.1)
==15348==    by 0x1BA17132: (within /usr/lib/libglib-2.0.so.0.800.1)
==15348==    by 0x1BA171F7: g_string_sized_new
(in /usr/lib/libglib-2.0.so.0.800.1)
==15348==    by 0x1BA17C45: g_string_new
(in /usr/lib/libglib-2.0.so.0.800.1)
==15348==    by 0x1B917A47: lookup_or_register_specialized
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15348==    by 0x1B918167: _dbus_gtype_from_signature_iter
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15348==    by 0x1B918276: _dbus_gtype_from_signature
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15348==    by 0x1B91591B: demarshal_static_variant
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15348==    by 0x1B9159A5: demarshal_variant
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15348==    by 0x1B91587C: _dbus_gvalue_demarshal
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15348==
==15348==
==15348== 64 bytes in 1 blocks are definitely lost in loss record 3 of
12
==15348==    at 0x1B902BE0: realloc (vg_replace_malloc.c:306)
==15348==    by 0x1BA0351E: g_realloc
(in /usr/lib/libglib-2.0.so.0.800.1)
==15348==    by 0x1BA17132: (within /usr/lib/libglib-2.0.so.0.800.1)
==15348==    by 0x1BA1781C: g_string_insert_len
(in /usr/lib/libglib-2.0.so.0.800.1)
==15348==    by 0x1BA17CF2: g_string_append
(in /usr/lib/libglib-2.0.so.0.800.1)
==15348==    by 0x1B917ABA: lookup_or_register_specialized
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15348==    by 0x804A5A3: my_object_class_intern_init
(in /usr/src/johnp/dbus/test/glib/.libs/lt-test-service-glib)
==15348==    by 0x1B9BBDCF: g_type_class_ref
(in /usr/lib/libgobject-2.0.so.0.800.1)
==15348==    by 0x1B9A495E: g_object_newv
(in /usr/lib/libgobject-2.0.so.0.800.1)
==15348==    by 0x1B9A4D73: g_object_new_valist
(in /usr/lib/libgobject-2.0.so.0.800.1)
==15348==    by 0x1B9A4F1B: g_object_new
(in /usr/lib/libgobject-2.0.so.0.800.1)
==15348==    by 0x804B23B: main
(in /usr/src/johnp/dbus/test/glib/.libs/lt-test-service-glib)
==15348==
==15348==
==15348== 70 (64 direct, 6 indirect) bytes in 1 blocks are definitely
lost in loss record 4 of 12
==15348==    at 0x1B901812: malloc (vg_replace_malloc.c:149)
==15348==    by 0x1BA0344F: g_malloc
(in /usr/lib/libglib-2.0.so.0.800.1)
==15348==    by 0x1BA240D3: g_io_channel_unix_new
(in /usr/lib/libglib-2.0.so.0.800.1)
==15348==    by 0x1B90BF16: connection_setup_add_watch
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15348==    by 0x1B90C1DC: add_watch
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15348==    by 0x1B954140: _dbus_watch_list_set_functions
(in /usr/src/johnp/dbus/dbus/.libs/libdbus-1.so.1.0.0)
==15348==    by 0x1B92F53B: dbus_connection_set_watch_functions
(in /usr/src/johnp/dbus/dbus/.libs/libdbus-1.so.1.0.0)
==15348==    by 0x1B90C4BE: dbus_connection_setup_with_g_main
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15348==    by 0x1B90C6D4: dbus_g_bus_get
(in /usr/src/johnp/dbus/glib/.libs/libdbus-glib-1.so.1.0.0)
==15348==    by 0x804B21E: main
(in /usr/src/johnp/dbus/test/glib/.libs/lt-test-service-glib)
==15348==
==15348==
==15348== 800 bytes in 20 blocks are possibly lost in loss record 5 of
12
==15348==    at 0x1B902AF4: calloc (vg_replace_malloc.c:279)
==15348==    by 0x1BA034BD: g_malloc0
(in /usr/lib/libglib-2.0.so.0.800.1)
==15348==    by 0x1B9B44BA: (within /usr/lib/libgobject-2.0.so.0.800.1)
==15348==    by 0x1B9B5FAA: (within /usr/lib/libgobject-2.0.so.0.800.1)
==15348==    by 0x1B9B61A3: g_type_init_with_debug_flags
(in /usr/lib/libgobject-2.0.so.0.800.1)
==15348==    by 0x1B9B6301: g_type_init
(in /usr/lib/libgobject-2.0.so.0.800.1)
==15348==    by 0x804B19E: main
(in /usr/src/johnp/dbus/test/glib/.libs/lt-test-service-glib)
==15348==
==15348== LEAK SUMMARY:
==15348==    definitely lost: 144 bytes in 3 blocks.
==15348==    indirectly lost: 6 bytes in 1 blocks.
==15348==      possibly lost: 800 bytes in 20 blocks.
==15348==    still reachable: 39833 bytes in 611 blocks.
==15348==         suppressed: 0 bytes in 0 blocks.


They look the same to me.  Perhaps you can apply your valgrind ninja eye
and tell me if if I am missing something.  I specifically restricted the
test suite to calling just the test I added.

-- 
John (J5) Palmieri <johnp at redhat.com>



More information about the dbus mailing list