GNOME Bugzilla – Bug 722664
crash when a locale cannot be converted to a time/date
Last modified: 2014-11-07 18:17:30 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.
Created attachment 266826 [details] [review] Avoid use of potential NULL values when date/time conversion fails
see also bug 719717
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.
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.
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 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
*** Bug 719717 has been marked as a duplicate of this bug. ***