[Bug 779426] New: emacs -gtk misinterprets floating-point numbers under certain locales
https://bugzilla.novell.com/show_bug.cgi?id=779426 https://bugzilla.novell.com/show_bug.cgi?id=779426#c0 Summary: emacs -gtk misinterprets floating-point numbers under certain locales Classification: openSUSE Product: openSUSE 12.2 Version: Final Platform: i686 OS/Version: openSUSE 12.2 Status: NEW Severity: Critical Priority: P5 - None Component: X11 Applications AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: Stromeko@NexGo.DE QAContact: qa-bugs@suse.de Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20100101 Firefox/15.0 When running emacs-gtk under a locale that doesn't have "." as the decimal point, the elisp interpreter will drop the fractional part of the number, e.g "0.25" will be interpreted as "0.0". The problem is _not_ present when setting LC_NUMERIC=C, running "emacs-gtk -nw" (no window system), emacs-x11 or emacs-nox. Reproducible: Always Steps to Reproduce: 1. Start "LC_NUMERIC=de_DE.UTF-8 emacs-gtk -Q" 2. Type "0.25" in *scratch* buffer, then "C-j" Actual Results: Input will evaluate to "0.0" instead of "0.25". Expected Results: Input should evaluate to "0.25". This happens after Tumbleweed rolled into 12.2. I've tested it on two different machines. The issue is present with Emacs 23.3 as delivered with the system, but also with different Emacs versions I have compiled myself from Emacs Bzr. Re-compiling on 12.2 did not help. I think this error relates to the update of glib from 2.14 to 2.15 somehow. Luckily I've noticed this problem very early in Gnus and start it wrapped as a workaround for now, but it has potential to create serious damage. Reported as bug#12392 to upstream. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c1
--- Comment #1 from Achim Gratz
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c
kk zhang
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c2
--- Comment #2 from Achim Gratz
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c3
Holger Arnold
I have compiled another Emacs with Gtk-3, but the behaviour stays the same, so it is not related to Gtk itself (or bot Gtk-2 and Gtk-3 would have the same bug).
The bug does not occur when Emacs is compiled with Motif or Athena widgets, which suggests that this problem is, at least indirectly, related to GTK. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c
Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c
Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c4
--- Comment #4 from Achim Gratz
See Bug #779426 for another symptom of this bug.
Sorry, that should read Bug #779248 of course. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c5
--- Comment #5 from Achim Gratz
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c6
--- Comment #6 from Achim Gratz
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c7
--- Comment #7 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c8
--- Comment #8 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c9
--- Comment #9 from Achim Gratz
echo $CHARSET CHARSET: Undefined variable. echo $LANG de_DE.UTF-8 emacs-gtk -Q
-- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c10
Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c11
--- Comment #11 from Achim Gratz
Somehow the gtk libs set LC_NUMERIC back and this even with LC_ALL=C ...
Again, emacs itself tries to use setlocale from within emacs, but that setting ends up being ignored. Why any library would manage to subvert that call and use a different locale I really don't know and I don't see how this can be the right thing in any circumstance.
in other words there is a environment variable or file in the system or your HOME from which the gtk libs or better the glib2 does do this. You should investigate here into th fully deep
Any idea where to start? Just for reference, root doesn't have that problem: it defaults to using LANG=C and even if I set LANG=de_DE.UTF-8 or LC_NUMERIC=de_DE.UTF-8 emacs still works correctly. In my own account it does work if I undefine LANG, but doesn't when it is set to LANG=de_DE.UTF-8 unless I also set LC_NUMERIC=C. I've even tried to undefine all other environment variables and still get the same behaviour. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c12
--- Comment #12 from Holger Arnold
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c13
--- Comment #13 from Holger Arnold
Guess: Are you have defined the environment variable CHARSET? And if so please report the value of the variable CHARSET.
Remark: I'm not able to reproduce
The problem occurs on a clean openSUSE 12.2, installed from the KDE live CD, with language set to German, so it should not be that hard to reproduce. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c14
--- Comment #14 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c15
--- Comment #15 from Holger Arnold
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c16
--- Comment #16 from Holger Arnold
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c17
--- Comment #17 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c18
--- Comment #18 from Holger Arnold
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c19
Holger Arnold
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c20
Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c21
--- Comment #21 from Holger Arnold
Beside this gtk has a bug IMHO as setlocale() is designed dynamically, that is that after setlocale() is use to set LC_NUMERIC to "C" or "POSIX" this should be also applied by gtk.
In other words this is a upstream design flaw of gtk! This flaw become not legal even with the rational seen at http://developer.gnome.org/gtk/stable/gtk-General.html#gtk-set-locale
No, GTK is doing nothing wrong here. Note that GTK only calls setlocale(LC_ALL, ""), which sets the locale to the one specified by the *user*. The whole idea of locales is to let the user specify the format and language of numbers, dates and other text presented to or entered by him. Therefore, *every* localized program should actually make this call once after start. (Why GStreamer has to make this call again I don't know, though.) Generally, programs should not overwrite the user-set locale using setlocale(LC_*, "C"). A program which has to process (formal-language) text independently of the current locale must simply not use locale-dependent functions. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c22
--- Comment #22 from Holger Arnold
As I've a script starting emacs simply to be able to support several GUI you may specify the lines [...] in the bash script /usr/bin/emacs
I know how to do this, but, since there is such a trivial and safe work-around, shouldn't this be shipped as an update to 12.2? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c23
--- Comment #23 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c24
Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c25
--- Comment #25 from Holger Arnold
I'd like to ask if I should add the described work around in comment #20 for an update of emacs?
Yes, I think you should because (a) it's a trivial and safe work-around, (b) it is not impossible that this problem can cause data loss (for example, for people reading their mail with Emacs), and (c) many affected Emacs users won't find this bug report. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c26
Holger Arnold
No really as configurations files use only one numeric format normally the dot as separator. It should be possible to use in C program the setlocale(3) to switch on the fly between the variant used for configurations file or other file like found below /proc and switch back to the LC_NUMERIC of the users environment. Otherwise parser code like used in emacs will fail as this bug shows.
That's a problem with the parser code, really. Locales are intended for user interfaces, in the broadest sense. Configuration files and program code do not belong in this category. Switching locales back and forth is simply not the correct approach, even more so when there are multiple interacting components that all have their own idea about locales. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c27
--- Comment #27 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c28
--- Comment #28 from Holger Arnold
How do *you* would solve such a problem? OK you may reimplement e.g. scanf(3) and other glibc API functions only to avoid LC_NUMERIC to be able to parse configurations. But IMHO this is not what should be done.
That's exactly what I would consider the correct way to do it. If I have to parse a formal language, well, I *have* to write a parser for this language; there is no way to avoid this. You might might argue that, if you are in a completely controlled environment (a batch program like a compiler, for example), you could simply set the locale back to "C". But this simply does not work if you want to have any kind of localized user interface. Even if you just want to print an error message, you have to respect the locale of the user. What are you going to do then, switching the locale each time you switch between "natural language mode" and "formal language mode"? Think about it: you might even have formal text and natural language text in a single message. This simply won't work. Hence, the only sane way is to process formal language text using locale-independent functions. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c29
--- Comment #29 from Holger Arnold
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c30
--- Comment #30 from Achim Gratz
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c31
--- Comment #31 from Holger Arnold
The bug apparently is in gstreamer/gst.c(init_pre): here setlocale is called unconditionally. Why init_pre is called from gst_init_check (I think, that is not clear) remains a bit mysterious however since I only have the Git version available where the line numbers are quite different.
init_pre() is called from a GOption parse hook that is installed in gst_init_get_option_group(). What I find mysterious is that this bug did not show up in openSUSE versions <12.2. The setlocale() call has been in gst.c since 2004, and the build of GStreamer did not change much between 12.1 and 12.2. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c32
--- Comment #32 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c33
--- Comment #33 from Holger Arnold
Maybe one of those functions had become a constructor with the newer gcc. Nevertheless gstreamer should not override the locale set previously.
I'd like to now when gstreamer will be fixed.
I have created a GStreamer bug to track this issue: http://bugzilla.gnome.org/show_bug.cgi?id=685650 -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c34
Dominique Leuenberger
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c35
--- Comment #35 from Achim Gratz
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c36
--- Comment #36 from Achim Gratz
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c37
--- Comment #37 from Dominique Leuenberger
Oh, and maybe correct the spelling error in the patch file name...
Heh, thanks.. at least it was consistently mistyped :) I switched on publishing.. so those should hopefully get on the FTP site soon. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c38
--- Comment #38 from Achim Gratz
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c39
Dominique Leuenberger
I've added your repo to zypper and did a "dup --from repo". I got this message:
Problem: gstreamer-0_10-utils-unversioned-0.10.36-2.2.i586 obsoletes gstreamer-utils <= 0.10.36 provided by gstreamer-utils-0.10.36-3.6.1.i586 Solution 1: deinstallation of gstreamer-0_10-utils-unversioned-0.10.36-2.2.i586 Solution 2: deinstallation of gstreamer-utils-1.0.3-2.2.i586 Solution 3: keep obsolete gstreamer-utils-1.0.3-2.2.i586
Errr.. that one is weird... gstreamer-0_10-utils-unversioned has been introduced AFTER the 12.2 release... so I have to assume you do not have gstreamer from the distribution, right? Anyway.. thanks for the confirmation.. I'll submit this as online update. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c40
--- Comment #40 from Dominique Leuenberger
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c41
Dominique Leuenberger
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c42
--- Comment #42 from Achim Gratz
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c43
--- Comment #43 from Bernhard Wiedemann
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c44
Benjamin Brunner
https://bugzilla.novell.com/show_bug.cgi?id=779426
https://bugzilla.novell.com/show_bug.cgi?id=779426#c45
--- Comment #45 from Swamp Workflow Management
participants (1)
-
bugzilla_noreply@novell.com