[avahi] DBus issues

Stefan de Konink avahi at ml.kinkrsoftware.nl
Thu Sep 4 10:46:38 PDT 2008


Lennart Poettering schreef:
> Ah, so your are using the threaded event loop. This smells a lot like
> that you have some locking issues here: maybe you forgot to enclose
> code accessing the avahi client object in _lock() and _unlock()?

Should this *always* happen when something access the client? So for
every resolver that is created...?

> Please note that avahi is not thread-safe. However, it is
> threads-aware. i.e. it works fine in a threaded environment as long as
> you following the locking rules properly. 
> 
> The thing about bad memory accesses like this is that the problems
> usually show up at places where you don't expect.

I fixed some other things in my code that my trees are thread safe now
(by internal locking).

Tonight I saw the following thing:

*** glibc detected *** /opt/cherokee/sbin/cherokee-worker: double free
or corruption (fasttop): 0x00002aaaac08cc10 ***
======= Backtrace: =========
/lib/libc.so.6[0x2abecd9b0bc8]
/lib/libc.so.6(cfree+0x76)[0x2abecd9b2786]
/usr/lib/libdbus-1.so.3[0x2abed0512874]
/usr/lib/libdbus-1.so.3[0x2abed05131d1]
/usr/lib/libdbus-1.so.3[0x2abed0513306]
/usr/lib/libdbus-1.so.3[0x2abed0510aa8]
/usr/lib/libdbus-1.so.3[0x2abed0515513]
/usr/lib/libdbus-1.so.3(dbus_message_iter_append_basic+0xee)[0x2abed0515c5e]
/usr/lib/libdbus-1.so.3(dbus_message_append_args_valist+0x76)[0x2abed0516446]
/usr/lib/libdbus-1.so.3(dbus_message_append_args+0x8d)[0x2abed0516778]
/usr/lib/libavahi-client.so.3(avahi_service_resolver_new+0x208)[0x2abecf734d28]
/opt/cherokee/lib/cherokee/libplugin_virt.so[0x2abecf2c9705]
/usr/lib/libavahi-client.so.3(avahi_service_browser_event+0x1be)[0x2abecf731bee]
/usr/lib/libavahi-client.so.3[0x2abecf72f6a5]
/usr/lib/libdbus-1.so.3(dbus_connection_dispatch+0x2fa)[0x2abed050d30a]
/usr/lib/libavahi-client.so.3[0x2abecf735f56]
/usr/lib/libavahi-common.so.3(avahi_simple_poll_dispatch+0x5a)[0x2abed073f36a]
/usr/lib/libavahi-common.so.3(avahi_simple_poll_loop+0x1d)[0x2abed073f92d]
/usr/lib/libavahi-common.so.3[0x2abed07402ce]
/lib/libpthread.so.0[0x2abecd1e5017]
/lib/libc.so.6(clone+0x6d)[0x2abecda0bfdd]

...

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x41001950 (LWP 32450)]
0x00002abecd96e235 in raise () from /lib/libc.so.6
(gdb) bt
#0  0x00002abecd96e235 in raise () from /lib/libc.so.6
#1  0x00002abecd96f753 in abort () from /lib/libc.so.6
#2  0x00002abecd9ab518 in __libc_message () from /lib/libc.so.6
#3  0x00002abecd9b0bc8 in malloc_printerr () from /lib/libc.so.6
#4  0x00002abecd9b2786 in free () from /lib/libc.so.6
#5  0x00002abed0512874 in apply_and_free_fixups () from
/usr/lib/libdbus-1.so.3
#6  0x00002abed05131d1 in replacement_block_replace () from
/usr/lib/libdbus-1.so.3
#7  0x00002abed0513306 in _dbus_type_reader_set_basic () from
/usr/lib/libdbus-1.so.3
#8  0x00002abed0510aa8 in _dbus_header_set_field_basic () from
/usr/lib/libdbus-1.so.3
#9  0x00002abed0515513 in _dbus_message_iter_close_signature () from
/usr/lib/libdbus-1.so.3
#10 0x00002abed0515c5e in dbus_message_iter_append_basic () from
/usr/lib/libdbus-1.so.3
#11 0x00002abed0516446 in dbus_message_append_args_valist () from
/usr/lib/libdbus-1.so.3
#12 0x00002abed0516778 in dbus_message_append_args () from
/usr/lib/libdbus-1.so.3
#13 0x00002abecf734d28 in avahi_service_resolver_new
(client=0x2aaaac000b70, interface=1, protocol=0, name=0x2aaaac08c6ec
"leaseweb_domu",
    type=0x2aaaac08c700 "_domu._tcp", domain=0x2aaaac08c710 "local",
aprotocol=-1, flags=0, callback=0x2abecf2c9336 <resolve_callback>,
    userdata=0x2aaaac0009d0) at resolver.c:259
#14 0x00002abecf2c9705 in browse_callback (b=0x2aaaac001990,
interface=1, protocol=0, event=AVAHI_BROWSER_NEW, name=0x2aaaac08c6ec
"leaseweb_domu",
    type=0x2aaaac08c700 "_domu._tcp", domain=0x2aaaac08c710 "local",
flags=12, userdata=0x2aaaac0009d0) at handler_avahi.c:371
#15 0x00002abecf731bee in avahi_service_browser_event (client=<value
optimized out>, event=AVAHI_BROWSER_NEW, message=0x2aaaac001700) at
browser.c:777
#16 0x00002abecf72f6a5 in filter_func (bus=<value optimized out>,
message=0x2aaaac001700, userdata=0x2aaaac000b70) at client.c:245
#17 0x00002abed050d30a in dbus_connection_dispatch () from
/usr/lib/libdbus-1.so.3
#18 0x00002abecf735f56 in dispatch_timeout_callback (t=<value optimized
out>, userdata=0x2aaaac000f80) at ../avahi-common/dbus-watch-glue.c:107
#19 0x00002abed073f36a in avahi_simple_poll_dispatch (s=0x2aaaac000ac0)
at simple-watch.c:562
#20 0x00002abed073f92d in avahi_simple_poll_loop (s=0x2aaaac000ac0) at
simple-watch.c:638
#21 0x00002abed07402ce in thread (userdata=0x2aaaac000a70) at
thread-watch.c:73
#22 0x00002abecd1e5017 in start_thread () from /lib/libpthread.so.0
#23 0x00002abecda0bfdd in clone () from /lib/libc.so.6
#24 0x0000000000000000 in ?? ()


If you say... please lock around any client access (even inside
callbacks :S)... I'll try to do this. If you have other suggestions,
please make them.


Stefan


More information about the avahi mailing list