<div dir="ltr">hey all,<br><br>i've encountered a problem when using Dbus in an ARM environment (actually in Android).<br>i have the following stack trace:<br><br>#0 __dl__start () at bionic/linker/arch/arm/begin.S:35<br>
#1 0xae832a46 in _dbus_abort () at external/dbus/dbus/dbus-sysdeps.c:84<br>#2 0xae817e3e in _dbus_real_assert (condition=<value optimized out>, condition_text=0xae83f318 "message->refcount.value == 0", <br>
file=0xae83eff8 "external/dbus/dbus/dbus-message.c", line=576, func=0xae8407bc "dbus_message_cache_or_finalize")<br> at external/dbus/dbus/dbus-internals.c:813<br>#3 0xae82236a in dbus_message_cache_or_finalize (message=0x18f420) at external/dbus/dbus/dbus-message.c:576<br>
#4 0xae82246a in dbus_message_unref (message=0x18f420) at external/dbus/dbus/dbus-message.c:1402<br><br>when debugging closer we have<br><br>(gdb) f 3<br>#3 0xae82236a in dbus_message_cache_or_finalize (message=0x18f420) at external/dbus/dbus/dbus-<div dir="ltr">
message.c:576<br>
576 _dbus_assert (message->refcount.value == 0);<br>(gdb) p message->refcount<br>$30 = {value = 1}<br><br>and in the unref we get:<br><br>(gdb) f 4<br>#4 0xae82246a in dbus_message_unref (message=0x18f420) at external/dbus/dbus/dbus-message.c:1402<br>
1402 dbus_message_cache_or_finalize (message);<br>(gdb) l -5<br>1387 dbus_message_unref (DBusMessage *message)<br>1388 {<br>1389 dbus_int32_t old_refcount;<br>1390 <br>1391 _dbus_return_if_fail (message != NULL);<br>
1392 _dbus_return_if_fail (message->generation == _dbus_current_generation);<br>1393 _dbus_return_if_fail (!message->in_cache);<br>1394 <br>1395 old_refcount = _dbus_atomic_dec (&message->refcount);<br>
1396 <br>(gdb) l<br>1397 _dbus_assert (old_refcount >= 0);<br>1398 <br>1399 if (old_refcount == 1)<br>1400 {<br>1401 /* Calls application callbacks! */<br>1402 dbus_message_cache_or_finalize (message);<br>
1403 }<br>1404 }<br>1405 <br>1406 /**<br>(gdb) p old_refcount<br>$32 = 1<br><br><br>seems like the dbus_atomic_dec function is not really "atomic" (in the sense the value is not immediately updated).<br>
note that in my version of dbus (based on 1.0.3 i believe) the "_dbus_atomic_dec" function does not use "atomic_exchange_and_add". <br>the function is defined as follows:<br><br>dbus_int32_t<br>_dbus_atomic_dec (DBusAtomic *atomic)<br>
{<br>#ifdef DBUS_USE_ATOMIC_INT_486<br> return atomic_exchange_and_add (atomic, -1);<br>#else<br> dbus_int32_t res;<br> <br> _DBUS_LOCK (atomic);<br> res = atomic->value;<br> atomic->value -= 1;<br> _DBUS_UNLOCK (atomic);<br>
return res;<br>#endif<br>}<br><br><br>and in the android dbus version we have the macro definition:<br><br>#undef DBUS_USE_ATOMIC_INT_486<br><br>#if (defined(__i386__) || defined(__x86_64__))<br>#define DBUS_USE_ATOMIC_INT_486 1<br>
#endif<br><br>i noticed this was changed in 1.2.4 to be a constant 1 (and thus use the "atomic_exchange_and_add" function).<br>should this solve my problem?<br><br>BR,<br>Jim<br><br></div><br></div>