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: 15 Dec 2003 08:14:21 -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 2003-12-15 08:14 -------
>+ _S_initialize();
>+ _S_global->_M_add_reference();
>+ _M_impl = _S_global;
This still looks wrong. Consider if one thread runs locale::locale() and
yields after _S_global->_M_add_reference(); Another thread then runs
locale::global() from start to finish. The second thread then completes
locale::locale(). In that case locale::locale() increases the reference
count of the old global locale, but keeps a pointer to the new global locale.
The old global locale gets leaked, and the new global locale will be deleted
while there are still pointers to it.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12658