This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/12658] Thread safety problems in locale::global() and locale::locale()
- From: "peturr02 at ru dot is" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Jul 2004 17:40:50 -0000
- Subject: [Bug libstdc++/12658] Thread safety problems in locale::global() and locale::locale()
- References: <20031017095219.12658.peturr02@ru.is>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From peturr02 at ru dot is 2004-07-28 17:40 -------
The problem in locale::locale() is still present:
__glibcxx_mutex_define_initialized(locale_cons_mutex);
__glibcxx_mutex_define_initialized(locale_global_mutex);
} // namespace __gnu_internal
namespace std
{
using namespace __gnu_internal;
locale::locale() throw() : _M_impl(0)
{
_S_initialize();
__gnu_cxx::lock sentry(__gnu_internal::locale_cons_mutex);
_S_global->_M_add_reference();
_M_impl = _S_global;
}
locale
locale::global(const locale& __other)
{
_S_initialize();
_Impl* __old;
{
__gnu_cxx::lock sentry(__gnu_internal::locale_global_mutex);
__old = _S_global;
__other._M_impl->_M_add_reference();
_S_global = __other._M_impl;
Note that while locale::locale() and locale::global() both lock a mutex
before touching _S_global, they lock different mutexes. There is thus nothing
to stop one thread from executing locale::global() while another executes
locale::locale(). As already noted, this can (and does) lead to serious
problems.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12658