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 722664 - crash when a locale cannot be converted to a time/date
crash when a locale cannot be converted to a time/date
Status: RESOLVED FIXED
Product: gnome-desktop
Classification: Core
Component: general
3.11.x
Other Linux
: Normal critical
: ---
Assigned To: Desktop Maintainers
Desktop Maintainers
: 719717 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-01-21 00:18 UTC by Peter Hutterer
Modified: 2014-11-07 18:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Avoid use of potential NULL values when date/time conversion fails (2.43 KB, patch)
2014-01-21 00:20 UTC, Peter Hutterer
none Details | Review
wall-clock: Replace ratio with colon on non-UTF-8 locales (2.30 KB, patch)
2014-01-21 21:07 UTC, Rui Matos
committed Details | Review

Description Peter Hutterer 2014-01-21 00:18:28 UTC
When a bad locale setting is set, or a locale that doesn't translate the date string, gnome-shell crashes when trying to display the time at the top. In my case I had (for reasons I can't remember) LANG=en_US, which caused g_date_time_format() to return NULL and thus this._clock.clock be null. That causes an exception.

A similar report seems to be 
https://bugzilla.redhat.com/show_bug.cgi?id=890708, if the locale is th_TH.UTF-8 the clock is fine but the conversion .toLocaleFormat fails and returns NULL, which again causes gnome-shell to crash.

Now, the locale I had set is wrong, but I must've had that for months because I can't remember when I set it. I only noticed when after an update gnome-shell kept crashing (and thus gdm), which was rather inconvenient. I'll attach a hack to work around and continue gracefully without displaying the time.
Comment 1 Peter Hutterer 2014-01-21 00:20:01 UTC
Created attachment 266826 [details] [review]
Avoid use of potential NULL values when date/time conversion fails
Comment 2 Ray Strode [halfline] 2014-01-21 18:25:11 UTC
see also bug 719717
Comment 3 Rui Matos 2014-01-21 18:38:36 UTC
The root cause of this is that the translation of the format string in gnome-desktop isn't convertible to the en_US locale codeset (ISO-8859-1):

LC_ALL=en_US.utf8 LANG=$LC_ALL gettext gnome-desktop-3.0 "%a %R" | iconv -f UTF-8 -t ISO-8859-1
%a %Hiconv: illegal input sequence at position 5

and g_date_time_format_locale() needs to convert the format string, which is UTF-8 as returned by gettext, to the current locale enconding. See https://bugzilla.gnome.org/show_bug.cgi?id=668250 .

I'm going to attach a fix for this in gnome-desktop by replacing the special character with a plain ':' when needed.
Comment 4 Rui Matos 2014-01-21 21:07:24 UTC
Created attachment 266924 [details] [review]
wall-clock: Replace ratio with colon on non-UTF-8 locales

Some of our translations use the ratio symbol which isn't convertible
to non-UTF-8 locale encodings which causes g_date_time_format() to
fail. Work around it by replacing the ratio symbol with a plain
colon.
Comment 5 Matthias Clasen 2014-01-22 02:05:37 UTC
Review of attachment 266924 [details] [review]:

::: libgnome-desktop/gnome-wall-clock.c
@@ +257,3 @@
+		p += 1;
+	}
+	*p = '\0';

If you are not super-concerned about the efficiency, you can probably get this done quicker with

  pieces = g_strsplit (input, ratio, -1);
  g_strjoinv (":", pieces);
Comment 6 Rui Matos 2014-02-03 17:29:16 UTC
Comment on attachment 266924 [details] [review]
wall-clock: Replace ratio with colon on non-UTF-8 locales

Pushed a simpler version as suggested.

Attachment 266924 [details] pushed as 1b9b7a2 - wall-clock: Replace ratio with colon on non-UTF-8 locales
Comment 7 Ray Strode [halfline] 2014-11-07 18:17:30 UTC
*** Bug 719717 has been marked as a duplicate of this bug. ***