Bug 105492 - fontconfig-2.13.0 globally sets the locale from the environment
Summary: fontconfig-2.13.0 globally sets the locale from the environment
Status: RESOLVED FIXED
Alias: None
Product: fontconfig
Classification: Unclassified
Component: library (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: fontconfig-bugs
QA Contact: Behdad Esfahbod
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-13 21:20 UTC by Ulrich Müller
Modified: 2018-09-08 06:42 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Müller 2018-03-13 21:20:07 UTC
Function FcConfigEnsure globally sets the locale by doing:
        setlocale (LC_ALL, "");

This countermands any locale settings in the calling program. For example, GNU Emacs sets LC_NUMERIC to "C" which is undone by the fontconfig library. In turn, this breaks Emacs' lisp reader.

See also:
Gentoo bug: https://bugs.gentoo.org/650332
GNU Emacs bug: https://debbugs.gnu.org/30788
Comment 1 Akira TAGOH 2018-03-14 03:41:49 UTC
fixed in git 923b5be. thanks.
Comment 2 Ulrich Müller 2018-03-14 21:19:34 UTC
(In reply to Akira TAGOH from comment #1)
> fixed in git 923b5be. thanks.

Unfortunately, this doesn't fix it. The following will still break Emacs (e.g. latest released version 25.3):

   $ unset LANG LC_ALL
   $ LC_NUMERIC=de_DE.UTF-8 emacs -Q
Comment 3 Akira TAGOH 2018-03-15 03:54:34 UTC
Hm, okay. I should leave the locale setting to applications then even though one might misses features if they don't do the right thing there. removed the locale related code in git.
Comment 4 Jonathan Nieder 2018-04-12 09:11:38 UTC
Reopening per comment 3.
Comment 5 Jonathan Nieder 2018-04-12 09:13:28 UTC
Ah, silly me: fixed by

commit 98eaef69af1350e459bf9c175476d3b772968874
Author: Akira TAGOH <akira@tagoh.org>
Date:   Thu Mar 15 12:17:52 2018 +0900
    Leave the locale setting to applications
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105492
Comment 6 Ethan Merritt 2018-09-07 19:33:55 UTC
Although this thread indicates that the problem has been resolved, this does not seem to be the case in the current git source.  The changes introduced by 98eaef69 are still present.  I.e. in multiple places the code calls setlocale(LC_all,"").  This clobbers the current locale settings established by the callling program.

I got here by debugging a problem reported against current gnuplot that so far as I can tell is directly caused by this change to libfontconfig.  The program sets and relies on LC_NUMERIC == "C", but after calling into libfontconfig this may have been changed to something else.  In particular if the default locale from the environment uses comma as a decimal point, bad things happen.

I suggest that 98eaef69 be reverted. A library call should not change the caller's locale.
Comment 7 Akira TAGOH 2018-09-08 06:42:06 UTC
I don't see what exactly issues you are facing. there are no code such as calling setlocale in the latest library anymore but keeps it in standalone tools. that shouldn't affects other programs.
plus, 98eaef69 is to revert changes like 923b5be6 and 9a0fcb94, and it is same what you were complaining. you seem getting confused. anyway, please mention what version of fontconfig you were trying and check if it is the latest or not. if you are using fontconfig from the package of any distro, please ask for maintainer to fix this. this has been fixed in 2.13.1 anyway.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.