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 685650 - GStreamer should not set the locale
GStreamer should not set the locale
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal normal
: 1.1.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-10-07 10:38 UTC by Holger Arnold
Modified: 2012-11-20 11:57 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Holger Arnold 2012-10-07 10:38:39 UTC
The function init_pre() in gstreamer/gst/gst.c calls setlocale(LC_ALL, ""), which sets the locale to the values specified in the environment.  This is wrong for two reasons:

1. It is absolutely not the task of a library to decide on the correct locale for a program.  Some programs change the locale for various (good or bad) reasons, and libraries should respect that.  Programs where GStreamer's overwriting of the locale causes bugs include Emacs [1, 2], Sublime Text [3], and Lua [4].

[1] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12392
[2] http://bugzilla.novell.com/show_bug.cgi?id=779426
[3] http://www.sublimetext.com/forum/viewtopic.php?f=3&t=8543
[4] https://github.com/pavouk/lgi/issues/19

Note that setting the locale can cause problems for programs that are not even linked against GStreamer.  In the case of Emacs, for example, GStreamer seems to be initialized through GTK via libcanberra.

2. Setting the locale is not thread-safe, and therefore should not be done in a library.
Comment 1 Sebastian Dröge (slomo) 2012-11-20 11:57:35 UTC
commit 9326124581e65c7f4dc6a729f12c1dca77d564f3
Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
Date:   Tue Nov 20 12:56:12 2012 +0100

    gst: Don't set the locale in gst_init()
    
    The function init_pre() in gstreamer/gst/gst.c calls setlocale(LC_ALL, ""),
    which sets the locale to the values specified in the environment.  This is
    wrong for two reasons:
    
    1. It is absolutely not the task of a library to decide on the correct locale
    for a program.  Some programs change the locale for various (good or bad)
    reasons, and libraries should respect that.  Programs where GStreamer's
    overwriting of the locale causes bugs include Emacs [1, 2], Sublime Text [3],
    and Lua [4].
    
    [1] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12392
    [2] http://bugzilla.novell.com/show_bug.cgi?id=779426
    [3] http://www.sublimetext.com/forum/viewtopic.php?f=3&t=8543
    [4] https://github.com/pavouk/lgi/issues/19
    
    Note that setting the locale can cause problems for programs that are not even
    linked against GStreamer.  In the case of Emacs, for example, GStreamer seems
    to be initialized through GTK via libcanberra.
    
    2. Setting the locale is not thread-safe, and therefore should not be done in a
    library.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=685650