[avahi] corrupted double-linked list

Gaspard Bucher gaspard at teti.ch
Fri May 8 15:06:52 PDT 2009


I'm not touching anything from the Implementation class (where the
avahi thread is running) so this does not seem to be the problem.

I also get a "Bad State" error while doing the group entry commit even
though my code path is exactly the same as the example:

create_client ---> client_callback --->
AVAHI_CLIENT_S_RUNNING ? ---> create_services ---> create group
---> add service ---> commit

How can I get a "Bad State" error when the client is running fine and
all creation steps and group setup did not return any error ?


current code: http://github.com/rubyk/rubyk/tree/master/oscit/src/linux

This dump shows the exact path:
#4  0x08123c90 in
(this=0x8d05080) at
#5  0x08123d04 in
(client=0x8d07230, state=AVAHI_CLIENT_S_RUNNING, context=0x8d05080)
    at /home/gaspard/git/rubyk/oscit/src/linux/zeroconf_registration.cpp:139
#6  0xb806316a in client_set_state (client=0x8d07230,
state=AVAHI_SERVER_RUNNING) at client.c:101
#7  0xb806361f in init_server (client=0x8d07230, ret_error=0xb6d682c4)
at client.c:327
#8  0xb8064560 in avahi_client_new (poll_api=0x8d06dc8, flags=0,
AvahiClientState, void*)>, userdata=0x8d05080, ret_error=0xb6d682c4)
    at client.c:585
#9  0x08123896 in
oscit::ZeroConfRegistration::Implementation::do_start (this=0x8d05080)
at /home/gaspard/git/rubyk/oscit/src/linux/zeroconf_registration.cpp:56
#10 0x0812394d in Implementation (this=0x8d05080, master=0x8d05048) at
#11 0x0812358d in ZeroConfRegistration (this=0x8d05048,
name=@0xb6d68364, service_type=0x814c883 "_oscit._udp", port=7010)
    at /home/gaspard/git/rubyk/oscit/src/linux/zeroconf_registration.cpp:203

On Fri, May 8, 2009 at 10:34 PM, Lennart Poettering
<lennart at poettering.net> wrote:
> On Fri, 08.05.09 09:11, Gaspard Bucher (gaspard at teti.ch) wrote:
>> I cannot seem to get avahi to work in my application. During runtime I get
>> *** glibc detected *** ... corrupted double-linked list
>> This seems to be related to avahi in very strange ways. Has anyone
>> experienced such problems when using avahi ?
>> Any help would be greatly appreciated. I really feel stupid here...
>> code:
>> http://github.com/rubyk/rubyk/tree/master/oscit/src/linux
> Uh. I don't really grok that code. Bu uh, you seem not to lock the
> threaded main loop ever. Which gives me the idea that this issue is
> simply a race issue, because of incomplete locking.
> Please note that Avahi is not thread-safe by itself. It offers you a
> few tools to use it in a threaded environment however. But you have to
> do all locking explicitly yourself, Avahi won't do it for you implicitly.
> Basically the idea is that after you started the threaded event loop
> if you need to touch the avahi context in anyway from anothe thread
> you have to lock the event loop first (i.e. temporarily interrupt its
> execution) and then unlock after your access.
> i.e. something like this:
> <snip>
> /* First lock things */
> avahi_threaded_poll_lock(ml);
> /* The call Avahi client functions */
> foo = avahi_client_xxx(bar);
> waldo = avahi_service_browser_yyy(humpf);
> /* When you are done, unlock things again */
> avahi_threaded_poll_unlock(ml);
> </snip>
> This locking logic works very similar to Java monitors if you know
> those. Or it's even a bit like the MT support in the GLib event loop.
> Hope this helps,
> Lennart
> --
> Lennart Poettering                        Red Hat, Inc.
> lennart [at] poettering [dot] net
> http://0pointer.net/lennart/           GnuPG 0x1A015CC4
> _______________________________________________
> avahi mailing list
> avahi at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/avahi

More information about the avahi mailing list