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

John (J5) Palmieri johnp at
Thu Sep 22 16:08:50 PDT 2005

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

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_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
) 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/
#3  0x0000003a92b2e929 in g_log () from /usr/lib64/
#4  0x0000003a92b2e997 in g_assert_warning ()
from /usr/lib64/
#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,
    user_data=0x7fffffae8160) at dbus-gvalue-utils.c:467
#9  0x0000003a92b19c50 in g_hash_table_foreach ()
from /usr/lib64/
#10 0x0000003722c1750e in hashtable_iterator (hash_type=5431712,
    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>

More information about the dbus mailing list