After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 770979 - gweather_info_update gives segfault if the libsoup cache fails to initialise
gweather_info_update gives segfault if the libsoup cache fails to initialise
Status: RESOLVED FIXED
Product: libgweather
Classification: Core
Component: general
3.20.x
Other Linux
: Normal normal
: future
Assigned To: libgweather-maint
libgweather-maint
Depends on:
Blocks:
 
 
Reported: 2016-09-07 02:45 UTC by bob
Modified: 2016-12-22 15:58 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description bob 2016-09-07 02:45:24 UTC
At the moment I'm fiddling with something which (for the time being) requires me to have HOME set to a dummy value (/dev/null). The get_cache function[1] returns null if the cache directory failed to be created, but ref_session[2] doesn't check whether the returned SoupCache is non-null. Instead of falling back to an XDG temp dir or just disabling the cache, this causes a segfault.

[1]: https://git.gnome.org/browse/libgweather/tree/libgweather/gweather-weather.c#n466
[2]: https://git.gnome.org/browse/libgweather/tree/libgweather/gweather-weather.c#n495
Comment 1 Giovanni Campagna 2016-09-07 03:04:22 UTC
I'm not sure that's a bug.
You can't really have $HOME set to anything but a directory owner by the current user with mode at least 0700. A lot of software will break (especially if it's not even a directory! How do you even cd into it?), even before a graphical session.

Then again in your case you should be able to workaround it by setting XDG_CACHE_HOME while running gnome-weather (or any other libgweather using app).
Comment 2 bob 2016-09-07 03:17:24 UTC
This particular application is headless, running as a DBus service. But regardless, software really ought not to break in a situation from which they can gracefully recover (particularly not libraries).

Even if it were to break, a segfault is not an acceptable failure mode. Even if g_error were called to say that the directory failed to be created and the reason, that would have saved me digging around in GDB to work out what happened (although I would still argue that libraries terminating an application is bad juju).

There may be a host of reasons why a directory couldn't be created, and there are alternatives that libgweather can pursue. All the other software running in my mocked environment call g_critical to emit an error message and gracefully degrade, there's not really a good reason for libgweather not to do the same.

If you like, I can try and write a patch to demonstrate the fix I have in mind, but it might need some extra scrutiny since my memory management isn't fantastic.
Comment 3 Giovanni Campagna 2016-12-22 15:58:52 UTC
I still think your setup is broken, but I pushed a fix to emit a warning
instead of crashing.
The fix will be in the next release.