GNOME Bugzilla – Bug 770979
gweather_info_update gives segfault if the libsoup cache fails to initialise
Last modified: 2016-12-22 15:58:52 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
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).
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.
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.