Travis Vitek wrote:
The same problem exists for __rw_get_numpunct.
In that case we should probably make the same changes in both,
referencing the respective issues in each ChangeLog, i.e.,
(presumably) STDCXX-453 in the patch below and STDCXX-452 in
the one for __rw_get_numpunct.
Martin
Farid Zaripov wrote:
The __rw_get_moneypunct () function in punct.cpp is not thread safe
for the same
facets. If this function is invoked with the same pfacet parameter in
dirrerent threads
simultaneously, then some one thread successfully create __rw_setlocale
object
but other threads will blocked by global mutex in __rw_setlocale ctor.
Then when
the mutex will be released after the updating pfacet->_C_data(), the
next thread will
do the same initialization as the first thread.
ChangeLog:
* punct.cpp (__rw_get_moneypunct): After creating __rw_setlocale
object check
if the locale data is initialized by another thread to prevent
multiple initialization\
of the locale data in facet.
----------
Index: punct.cpp
===================================================================
--- punct.cpp (revision 580097)
+++ punct.cpp (working copy)
@@ -308,6 +308,10 @@
// set all categories -- need LC_NUMERIC and LC_CTYPE
const __rw_setlocale clocale (locname, _RWSTD_LC_ALL);
+ if (pfacet->_C_data ())
+ // call self recursively on already initialized in another
thread `impdata'
+ return __rw_get_moneypunct (pfacet, flags);
+
// get the lconv data
const lconv* const pconv = localeconv ();
if (!pconv)
----------
Farid.