[avahi] Problems with avahi segfaulting when cleaning up resources

Jim Hodapp james.hodapp at gmail.com
Wed Oct 29 13:46:18 PDT 2008


I went ahead and made my own thread instead putting the
"avahi_simple_poll_loop(simple_poll);" call in the new thread's main
function. I still get the exact same results as when using the built
in thread in Avahi and the "avahi_threaded_poll_start(threaded_poll)"
call instead of the simple_poll. I'm not quite sure where to go from
here. It does seem to be a timing/race condition within Avahi as it
seems that the first several times I run my app linked against
avahi-core that it won't segfault or abort, then it starts to segfault
and abort whenever I press CNTRL+C on my keyboard to shutdown my app.

Any suggestions?

Thanks,

Jim Hodapp


On Sun, Oct 26, 2008 at 10:41 AM, Lennart Poettering
<lennart at poettering.net> wrote:
> On Fri, 24.10.08 13:45, Jim Hodapp (james.hodapp at gmail.com) wrote:
>
>> I am using Avahi version 0.6.14 and am trying to use it on an embedded
>> ARM11 processor. I am using the example avahi-core for publishing a
>> service, but modified it to use a threaded-poll instead of the simple
>> poll. So when trying to unpublish any services published with avahi
>> and freeing any resources that it used, Avahi seems to randomly
>> complete sometimes, sometimes abort (due to asserts not evaluating to
>> true) and sometimes segfault. I am not sure why this is happening,
>> perhaps I am not freeing things correctly.
>>
>> Here is my unpublish function:
>>
>> int unpublish_services()
>> {
>>       int ret = 0;
>>
>>       avahi_threaded_poll_lock(threaded_poll);
>>
>>       avahi_threaded_poll_stop(threaded_poll);
>>
>>       avahi_threaded_poll_unlock(threaded_poll);
>
> _stop() is should be called unlocked. It locks internally anyway and the
> mutex is not recursive.
>
>>
>>       avahi_free(name);
>>
>>       if (server)
>>               avahi_server_free(server);
>>       else
>>               ret = -1;
>>
>>       if (threaded_poll)
>>               avahi_threaded_poll_free(threaded_poll);
>>       else
>>               ret = -1
>>
>>       return ret;
>> }
>
> Otherwise the logic looks about right to me. i.e. first, stop the
> poll, then free the server, then free the poll.
>
> Lennart
>
> --
> Lennart Poettering                        Red Hat, Inc.
> lennart [at] poettering [dot] net         ICQ# 11060553
> 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