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

John (J5) Palmieri johnp at redhat.com
Fri Sep 23 14:06:52 PDT 2005


Seems like variants got missed when dealing with containers.  It was a
simple fix switching out the marshal_basic call with
_dbus_gvalue_marshal.  Patch is attached with test case.  Ok to commit?

On Thu, 2005-09-22 at 19:08 -0400, John (J5) Palmieri wrote:
> I have some code that needs to marshal a byte array in a hash of
> variants.  It seems that the code path being taken can only handle basic
> types.
> 
> First stuffing the byte array into a GValue part:
> 
> func (..., const guchar *value, gsize len)
> {
>   .
>   .
>   .
>   byte_array = g_array_sized_new (FALSE, FALSE, sizeof(guchar), len);
>   byte_array = g_array_append_vals (byte_array, value, len);
> 
>   hint_value = g_new0 (GValue, 1);
>   g_value_init (hint_value, dbus_g_type_get_collection ("GArray",
> G_TYPE_UCHAR));
>   g_value_set_boxed_take_ownership (hint_value, byte_array);
> 
>   g_hash_table_insert (hints, key, hint_value);
> 
> }
> 
> The hints GHashTable is then marshaled at some point into a dbus
> message.  This all works fine for simple types but when I add the byte
> array to the hash it trys to marshal it as a basic type and reaches an
> assert in marshal_basic when the switch statement can't determine its
> type.  Weird thing is in marshal_variant it correctly gets the signature
> as ay.  I suspect we are not handling deep recursive types correctly.
> 
> Here is the backtrace:
> 
> #0  0x0000003719b2fbf0 in *__GI_raise (sig=Variable "sig" is not
> available.
> ) at ../nptl/sysdeps/unix/sysv/linux/raise.c:67
> #1  0x0000003719b310c0 in *__GI_abort ()
> at ../sysdeps/generic/abort.c:88
> #2  0x0000003a92b2e8a6 in g_logv () from /usr/lib64/libglib-2.0.so.0
> #3  0x0000003a92b2e929 in g_log () from /usr/lib64/libglib-2.0.so.0
> #4  0x0000003a92b2e997 in g_assert_warning ()
> from /usr/lib64/libglib-2.0.so.0
> #5  0x0000003722c147d1 in marshal_basic (iter=0x7fffffae7fc0,
> value=0x13b9) at dbus-gvalue.c:1211
> #6  0x0000003722c14dd0 in marshal_variant (iter=0x7fffffae8040,
> value=Variable "value" is not available.
> ) at dbus-gvalue.c:1479
> #7  0x0000003722c14fe2 in marshal_map_entry (key=0x7fffffae80e0,
> value=0x7fffffae80c0, data=Variable "data" is not available.
> )
>     at dbus-gvalue.c:1372
> #8  0x0000003722c1748c in hashtable_foreach_with_values (key=0x573f10,
> value=0x5720c0,
>     user_data=0x7fffffae8160) at dbus-gvalue-utils.c:467
> #9  0x0000003a92b19c50 in g_hash_table_foreach ()
> from /usr/lib64/libglib-2.0.so.0
> #10 0x0000003722c1750e in hashtable_iterator (hash_type=5431712,
> instance=0x528110,
>     iterator=0x3722c14f50 <marshal_map_entry>, user_data=0x7fffffae8200)
>     at dbus-gvalue-utils.c:489
> #11 0x0000003722c14cf6 in marshal_map (iter=0x7fffffae8250,
> value=0x582870) at dbus-gvalue.c:1437
> #12 0x0000003722c1046c in dbus_g_proxy_marshal_args_to_message
> (proxy=Variable "proxy" is not available.
> ) at dbus-gproxy.c:2023
> #13 0x0000003722c104ca in dbus_g_proxy_begin_call_internal
> (proxy=0x5a1ed0, method=Variable "method" is not available.
> )
>     at dbus-gproxy.c:2046
> #14 0x0000003722c11e27 in dbus_g_proxy_call (proxy=0x5a1ed0,
> method=0x2aaaaaab0215 "Notify",
>     error=0x7fffffae8560, first_arg_type=5777544) at dbus-gproxy.c:2352

-- 
John (J5) Palmieri <johnp at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbus-gvalue-marshal-container-variants.patch
Type: text/x-patch
Size: 3909 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20050923/98f534ab/dbus-gvalue-marshal-container-variants.bin


More information about the dbus mailing list