Bug 1281449

Summary: [abrt] geoclue2: avahi_client_free(): geoclue killed by SIGABRT
Product: [Fedora] Fedora Reporter: satellitgo
Component: geoclue2Assignee: Matthias Clasen <mclasen>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 24CC: bnocera, harald, jfrieben, klember, mclasen, satellitgo, trent, vondruch
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
URL: https://retrace.fedoraproject.org/faf/reports/bthash/a1db61736418a025e5ac5fafa0373d1e0872ea3a
Whiteboard: abrt_hash:495fb04adbce4c777c950f5055731fb43645eef0;VARIANT_ID=workstation;
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-08 12:23:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
File: backtrace
none
File: cgroup
none
File: core_backtrace
none
File: dso_list
none
File: environ
none
File: limits
none
File: maps
none
File: mountinfo
none
File: namespaces
none
File: open_fds
none
File: proc_pid_status
none
File: var_log_messages
none
nmea-source: Fix avahi daemon not running problem
none
nmea-source: Init client from callback
none
nmea-source: Re-init client as fallback only
none
nmea-source: Re-init client as fallback only none

Description satellitgo 2015-11-12 14:50:44 UTC
Description of problem:
boot.iso rawhide 1111 workstation install to virt-manager  on first boot

Version-Release number of selected component:
geoclue2-2.4.0-1.fc24

Additional info:
reporter:       libreport-2.6.3
backtrace_rating: 4
cmdline:        /usr/libexec/geoclue -t 5
crash_function: avahi_client_free
executable:     /usr/libexec/geoclue
global_pid:     1497
kernel:         4.4.0-0.rc0.git6.1.fc24.x86_64
runlevel:       unknown
type:           CCpp
uid:            994

Truncated backtrace:
Thread no. 1 (6 frames)
 #4 avahi_client_free at client.c:626
 #5 gclue_nmea_source_finalize at gclue-nmea-source.c:596
 #7 g_list_foreach at glist.c:1005
 #8 g_list_free_full at glist.c:220
 #9 gclue_locator_finalize at gclue-locator.c:286
 #11 gclue_service_manager_finalize at gclue-service-manager.c:408

Comment 1 satellitgo 2015-11-12 14:50:48 UTC
Created attachment 1093320 [details]
File: backtrace

Comment 2 satellitgo 2015-11-12 14:50:49 UTC
Created attachment 1093321 [details]
File: cgroup

Comment 3 satellitgo 2015-11-12 14:50:50 UTC
Created attachment 1093322 [details]
File: core_backtrace

Comment 4 satellitgo 2015-11-12 14:50:51 UTC
Created attachment 1093323 [details]
File: dso_list

Comment 5 satellitgo 2015-11-12 14:50:52 UTC
Created attachment 1093324 [details]
File: environ

Comment 6 satellitgo 2015-11-12 14:50:53 UTC
Created attachment 1093325 [details]
File: limits

Comment 7 satellitgo 2015-11-12 14:50:54 UTC
Created attachment 1093326 [details]
File: maps

Comment 8 satellitgo 2015-11-12 14:50:55 UTC
Created attachment 1093327 [details]
File: mountinfo

Comment 9 satellitgo 2015-11-12 14:50:56 UTC
Created attachment 1093328 [details]
File: namespaces

Comment 10 satellitgo 2015-11-12 14:50:57 UTC
Created attachment 1093329 [details]
File: open_fds

Comment 11 satellitgo 2015-11-12 14:50:58 UTC
Created attachment 1093330 [details]
File: proc_pid_status

Comment 12 satellitgo 2015-11-12 14:51:00 UTC
Created attachment 1093331 [details]
File: var_log_messages

Comment 13 Vít Ondruch 2015-11-19 22:09:19 UTC
Another user experienced a similar problem:

This appears every time I logout/login and seems to be Wayland related.

reporter:       libreport-2.6.3
backtrace_rating: 4
cmdline:        /usr/libexec/geoclue -t 5
crash_function: avahi_client_free
executable:     /usr/libexec/geoclue
global_pid:     18688
kernel:         4.3.0-1.fc24.x86_64
package:        geoclue2-2.4.0-1.fc24
reason:         geoclue killed by SIGABRT
runlevel:       N 5
type:           CCpp
uid:            992

Comment 14 Vít Ondruch 2015-11-19 22:12:41 UTC
Actually I was wrong, I got this error even after logout/login into X session.

Comment 15 Zeeshan Ali 2015-11-23 18:25:17 UTC
Don't see anything wrong in code. Could you try running `/usr/libexec/geoclue -t 5` manually under gdb (this crash should be happening when geoclue timesout on no requests) and see what argument is being passed to avahi_client_free() after it crashes?

Comment 16 Zeeshan Ali 2015-11-23 18:25:58 UTC
Forgot to mention that you want to run geoclue either as root or 'geoclue' user.

Comment 17 Trent Lloyd 2015-11-24 23:43:05 UTC
Follow-up from IRC, reason it likely works when you run geoclue manually is that Avahi was already activated by some other service but when run automatically on boot or session start was not yet activated.

The patch from jaeckel fixes the crash, by getting the correct client pointer and not assuming it is valid.


To fix Avahi not connecting in this situation, it is possible to have avahi_client_new retry the connection automatically by passing the flag AVAHI_CLIENT_NO_FAIL in flags, see:
http://avahi.org/download/doxygen/client_8h.html#a46a797e5d352f6f98261834ae3b1a3ed

Let me know if using that fixes the issue.

Comment 18 Zeeshan Ali 2015-11-25 12:47:06 UTC
> Follow-up from IRC, reason it likely works when you run geoclue manually is
> that Avahi was already activated by some other service but when run
> automatically on boot or session start was not yet activated.

Doubtful cause Ankit (former SoC student) was able to reproduce both these cases 100% and he tried many times in a row.
 
> The patch from jaeckel fixes the crash, by getting the correct client
> pointer and not assuming it is valid.

Yeah, it does and I'll push it soon but I really would like to fix the actual issue.

 
> To fix Avahi not connecting in this situation, it is possible to have
> avahi_client_new retry the connection automatically by passing the flag
> AVAHI_CLIENT_NO_FAIL in flags, see:
> http://avahi.org/download/doxygen/client_8h.
> html#a46a797e5d352f6f98261834ae3b1a3ed
> 
> Let me know if using that fixes the issue.

I'll ask Ankit to try that out cause I'm unable to reproduce on my F23 machine.

The only thing I can think of, is selinux so can someone try with selinux disabled?

Comment 19 Ankit 2015-11-25 17:03:01 UTC
(In reply to Trent Lloyd from comment #17)
> To fix Avahi not connecting in this situation, it is possible to have
> avahi_client_new retry the connection automatically by passing the flag
> AVAHI_CLIENT_NO_FAIL in flags, see:
> http://avahi.org/download/doxygen/client_8h.
> html#a46a797e5d352f6f98261834ae3b1a3ed

I tried this. It just makes it go to 'bad state'.

Comment 20 Ankit 2015-11-25 17:20:01 UTC
(In reply to Zeeshan Ali from comment #18)
> I'll ask Ankit to try that out cause I'm unable to reproduce on my F23
> machine.
> 
> The only thing I can think of, is selinux so can someone try with selinux
> disabled?

This didn't help either.

Comment 21 Ankit 2015-11-25 18:06:11 UTC
Created attachment 1098933 [details]
nmea-source: Fix avahi daemon not running problem

This was being caused by unintialized priv->avahi_client inside
gclue_nmea_source_init. Initializing priv->avahi_client inside
client_callback fixes this problem.

Comment 22 Zeeshan Ali 2015-11-27 14:05:44 UTC
(In reply to Ankit from comment #21)
> Created attachment 1098933 [details]
> nmea-source: Fix avahi daemon not running problem
> 
> This was being caused by unintialized priv->avahi_client inside
> gclue_nmea_source_init. Initializing priv->avahi_client inside
> client_callback fixes this problem.

Does it? It's really strange. The documentation of avahi_client_new() is confusing as hell. This is what it says about the callback parameter:

"A callback that is called whenever the state of the client changes. This may be NULL. Please note that this function is called for the first time from within the avahi_client_new() context! Thus, in the callback you should not make use of global variables that are initialized only after your call to avahi_client_new(). A common mistake is to store the AvahiClient pointer returned by avahi_client_new() in a global variable and assume that this global variable already contains the valid pointer when the callback is called for the first time. A work-around for this is to always use the AvahiClient pointer passed to the callback function instead of the global pointer."

Comment 23 Zeeshan Ali 2015-11-27 16:55:28 UTC
*** Bug 1285843 has been marked as a duplicate of this bug. ***

Comment 24 Ankit 2015-11-27 21:17:42 UTC
(In reply to Zeeshan Ali from comment #22)
> (In reply to Ankit from comment #21)
> > Created attachment 1098933 [details]
> > nmea-source: Fix avahi daemon not running problem
> > 
> > This was being caused by unintialized priv->avahi_client inside
> > gclue_nmea_source_init. Initializing priv->avahi_client inside
> > client_callback fixes this problem.
> 
> Does it? It's really strange. The documentation of avahi_client_new() is
> confusing as hell. This is what it says about the callback parameter:
> 
> "A callback that is called whenever the state of the client changes. This
> may be NULL. Please note that this function is called for the first time
> from within the avahi_client_new() context! Thus, in the callback you should
> not make use of global variables that are initialized only after your call
> to avahi_client_new(). A common mistake is to store the AvahiClient pointer
> returned by avahi_client_new() in a global variable and assume that this
> global variable already contains the valid pointer when the callback is
> called for the first time. A work-around for this is to always use the
> AvahiClient pointer passed to the callback function instead of the global
> pointer."

How about we set priv->avahi_client iff it is null and avahi_client parameter of callback is not null?

Comment 25 Zeeshan Ali 2015-11-30 13:39:08 UTC
(In reply to Ankit from comment #24)
> (In reply to Zeeshan Ali from comment #22)
> > (In reply to Ankit from comment #21)
> > > Created attachment 1098933 [details]
> > > nmea-source: Fix avahi daemon not running problem
> > > 
> > > This was being caused by unintialized priv->avahi_client inside
> > > gclue_nmea_source_init. Initializing priv->avahi_client inside
> > > client_callback fixes this problem.
> > 
> > Does it? It's really strange. The documentation of avahi_client_new() is
> > confusing as hell. This is what it says about the callback parameter:
> > 
> > "A callback that is called whenever the state of the client changes. This
> > may be NULL. Please note that this function is called for the first time
> > from within the avahi_client_new() context! Thus, in the callback you should
> > not make use of global variables that are initialized only after your call
> > to avahi_client_new(). A common mistake is to store the AvahiClient pointer
> > returned by avahi_client_new() in a global variable and assume that this
> > global variable already contains the valid pointer when the callback is
> > called for the first time. A work-around for this is to always use the
> > AvahiClient pointer passed to the callback function instead of the global
> > pointer."
> 
> How about we set priv->avahi_client iff it is null and avahi_client
> parameter of callback is not null?

That doesn't answer my questions. Does this patch actually solves the issue? Why does avahi_client_new() returns a NULL?

Comment 26 Ankit 2015-11-30 15:09:36 UTC
(In reply to Zeeshan Ali from comment #25)
> That doesn't answer my questions. Does this patch actually solves the issue?
> Why does avahi_client_new() returns a NULL?

Yeah, it is working for me when I initialize priv->avahi_client inside client_callback. I'm not sure as to why avahi_client_new() returns NULL, but I'm trying to find it out.

Comment 27 Ankit 2015-11-30 15:11:14 UTC
(In reply to Ankit from comment #19)
> (In reply to Trent Lloyd from comment #17)
> > To fix Avahi not connecting in this situation, it is possible to have
> > avahi_client_new retry the connection automatically by passing the flag
> > AVAHI_CLIENT_NO_FAIL in flags, see:
> > http://avahi.org/download/doxygen/client_8h.
> > html#a46a797e5d352f6f98261834ae3b1a3ed
> 
> I tried this. It just makes it go to 'bad state'.

'bad state' was the error message that was set after passing flag AVAHI_CLIENT_NO_FAIL.

Comment 28 Zeeshan Ali 2015-11-30 16:27:44 UTC
(In reply to Ankit from comment #27)
> (In reply to Ankit from comment #19)
> > (In reply to Trent Lloyd from comment #17)
> > > To fix Avahi not connecting in this situation, it is possible to have
> > > avahi_client_new retry the connection automatically by passing the flag
> > > AVAHI_CLIENT_NO_FAIL in flags, see:
> > > http://avahi.org/download/doxygen/client_8h.
> > > html#a46a797e5d352f6f98261834ae3b1a3ed
> > 
> > I tried this. It just makes it go to 'bad state'.
> 
> 'bad state' was the error message that was set after passing flag
> AVAHI_CLIENT_NO_FAIL.

error message from where exactly?

Comment 29 Ankit 2015-11-30 16:30:52 UTC
Forgot to mention that I tried running avahi-browse and then ran Geoclue. avahi-browse could find the service but Geoclue got null value from avahi_client_new() and displayed error.

Comment 30 Ankit 2015-11-30 16:34:11 UTC
(In reply to Zeeshan Ali from comment #28)
> (In reply to Ankit from comment #27)
> > (In reply to Ankit from comment #19)
> > > (In reply to Trent Lloyd from comment #17)
> > > > To fix Avahi not connecting in this situation, it is possible to have
> > > > avahi_client_new retry the connection automatically by passing the flag
> > > > AVAHI_CLIENT_NO_FAIL in flags, see:
> > > > http://avahi.org/download/doxygen/client_8h.
> > > > html#a46a797e5d352f6f98261834ae3b1a3ed
> > > 
> > > I tried this. It just makes it go to 'bad state'.
> > 
> > 'bad state' was the error message that was set after passing flag
> > AVAHI_CLIENT_NO_FAIL.
> 
> error message from where exactly?

After getting error string corresponding to the value of error variable passed to avahi_client_new().

Comment 31 Zeeshan Ali 2015-11-30 17:20:16 UTC
I've pushed a modified version of the attached patch: http://cgit.freedesktop.org/geoclue/commit/?id=73bb65796b30ce9a6e917de951e3058c32900b98

I hope that fixes the actual issue, it worked for Ankit at least when he was able to reproduce this issue. I would still wish if some Avahi dev/expert could shed some light on what might be the issue here.

Comment 32 Ankit 2015-11-30 17:26:40 UTC
(In reply to Zeeshan Ali from comment #31)
> I've pushed a modified version of the attached patch:
> http://cgit.freedesktop.org/geoclue/commit/
> ?id=73bb65796b30ce9a6e917de951e3058c32900b98
> 
> I hope that fixes the actual issue, it worked for Ankit at least when he was
> able to reproduce this issue. I would still wish if some Avahi dev/expert
> could shed some light on what might be the issue here.

Wouldn't it be better if you set priv->avahi_client inside _init() and override its value if no error has occurred inside client_callback and priv->avahi_client is not already NULL?

Comment 33 Ankit 2015-11-30 17:36:45 UTC
Created attachment 1100572 [details]
nmea-source: Init client from callback

Apparently, sometimes avahi_client_new() can simply return a NULL
pointer and you get the real client pointer from the client callback
parameter. Let's initialize our client pointer from client callback
as a fallback.

Comment 34 Zeeshan Ali 2015-12-02 17:26:58 UTC
(In reply to Ankit from comment #32)
> (In reply to Zeeshan Ali from comment #31)
> > I've pushed a modified version of the attached patch:
> > http://cgit.freedesktop.org/geoclue/commit/
> > ?id=73bb65796b30ce9a6e917de951e3058c32900b98
> > 
> > I hope that fixes the actual issue, it worked for Ankit at least when he was
> > able to reproduce this issue. I would still wish if some Avahi dev/expert
> > could shed some light on what might be the issue here.
> 
> Wouldn't it be better if you set priv->avahi_client inside _init() and
> override its value if no error has occurred inside client_callback and
> priv->avahi_client is not already NULL?

Hmm.. sure! Your patch needs to be rebased though (and commit log updated too).

Comment 35 Ankit 2015-12-09 13:40:28 UTC
Created attachment 1103912 [details]
nmea-source: Re-init client as fallback only

Since avahi_client_new documentation says that callback function
can be called multiple times after avahi_client_new is called,
we wouldn't want to initialize client inside callback multiple
times. Instead we intialize the client from avahi_client_new
and re-initialize it inside callback function if the client
returned by avahi_client_new is NULL.

Comment 36 Ankit 2015-12-09 13:55:54 UTC
Created attachment 1103917 [details]
nmea-source: Re-init client as fallback only

Since avahi_client_new documentation says that callback function
can be called multiple times after avahi_client_new is called,
we wouldn't want to initialize client inside callback multiple
times. Instead we intialize the client from avahi_client_new
and re-initialize it inside callback function if the client
returned by avahi_client_new is NULL.

Comment 37 Zeeshan Ali 2015-12-10 14:53:34 UTC
While we still don't have any explanation of this weird avahi behaviour, the fixes in the new release (which has already been packaged for rawhide) should fix the issue.

Comment 38 Jan Kurik 2016-02-24 13:56:58 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 24 development cycle.
Changing version to '24'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora24#Rawhide_Rebase

Comment 40 Fedora End Of Life 2017-07-25 19:28:53 UTC
This message is a reminder that Fedora 24 is nearing its end of life.
Approximately 2 (two) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 24. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '24'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 24 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 41 Fedora End Of Life 2017-08-08 12:23:37 UTC
Fedora 24 changed to end-of-life (EOL) status on 2017-08-08. Fedora 24 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 42 Red Hat Bugzilla 2023-09-14 03:12:55 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days