Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 68313 invoked from network); 3 Apr 2008 17:15:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Apr 2008 17:15:30 -0000 Received: (qmail 98726 invoked by uid 500); 3 Apr 2008 17:15:31 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 98658 invoked by uid 500); 3 Apr 2008 17:15:30 -0000 Mailing-List: contact dev-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list dev@stdcxx.apache.org Received: (qmail 98649 invoked by uid 99); 3 Apr 2008 17:15:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Apr 2008 10:15:30 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.roguewave.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Apr 2008 17:14:41 +0000 Received: from exchmail01.Blue.Roguewave.Com (exchmail01.blue.roguewave.com [10.22.129.22]) by moroha.roguewave.com (8.13.6/8.13.6) with ESMTP id m33HF0jo030336 for ; Thu, 3 Apr 2008 17:15:00 GMT X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Subject: RE: svn commit: r644364 - in /stdcxx/trunk: src/locale_global.cpp tests/localization/22.locale.statics.mt.cpp Date: Thu, 3 Apr 2008 11:15:12 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: svn commit: r644364 - in /stdcxx/trunk: src/locale_global.cpp tests/localization/22.locale.statics.mt.cpp Thread-Index: AciVrVLOXVraJ5vzTlGcc3aN/qmJUgAANOtg References: <20080403153258.1820A1A9838@eris.apache.org> <47F4FDDE.7070109@roguewave.com> <47F50E8F.6000600@roguewave.com> From: "Eric Lemings" To: X-Virus-Checked: Checked by ClamAV on apache.org file src/setlocale.cpp: 83 // acquire global per-process lock 84 __rw_setlocale_mutex._C_acquire (); 85 86 // retrieve previous locale name and check if it is already set 87 const char* const curname =3D ::setlocale (cat, 0); The mutex doesn't need to be locked just to read the current locale name, does it?=20 Brad. > -----Original Message----- > From: Martin Sebor [mailto:sebor@roguewave.com]=20 > Sent: Thursday, April 03, 2008 11:06 AM > To: dev@stdcxx.apache.org > Subject: Re: svn commit: r644364 - in /stdcxx/trunk:=20 > src/locale_global.cpp tests/localization/22.locale.statics.mt.cpp >=20 > Travis Vitek wrote: > > =20 > >=20 > >> -----Original Message----- > >> From: Martin Sebor [mailto:sebor@roguewave.com]=20 > >> Sent: Thursday, April 03, 2008 8:55 AM > >> To: dev@stdcxx.apache.org > >> Subject: Re: svn commit: r644364 - in /stdcxx/trunk:=20 > >> src/locale_global.cpp tests/localization/22.locale.statics.mt.cpp > >> > >> elemings@apache.org wrote: > >>> Author: elemings > >>> Date: Thu Apr 3 08:32:56 2008 > >>> New Revision: 644364 > >>> > >>> URL: http://svn.apache.org/viewvc?rev=3D644364&view=3Drev > >>> Log: > >>> 2008-04-03 Eric Lemings > >>> > >>> STDCXX-811 > >>> * src/locale_global.cpp (std::locale::global): Replace call to > >>> non-reentrant setlocale() C function with reentrant > >>> __rw_setlocale object. > >> I don't think that's correct. The object's dtor restores > >> the original locale. We need a mutex around the call to > >> setlocale. Look for/at the _RWSTD_STATIC_GUARD() and > >> _RWSTD_CLASS_GUARD() macros. > >> > >=20 > > Right. It seems that for this to be mt-safe with respect to other > > library code that calls setlocale(), we would need to lock=20 > the same lock > > that is used by _RW::__rw_setlocale. If don't use the same=20 > lock it would > > be possible for the std::locale::global() call to change the locale > > while some other library code is reading locale specific data under > > protection of an active _RW::__rw_setlocale instance. >=20 > Good point. That probably means extending the __rw_setlocale > interface to release the lock without restoring the original > locale name. >=20 > >=20 > > Of course the _RW::__rw_setlocale objects will always be=20 > able to call > > setlocale() and mess up the state of anything expecting=20 > locale specific > > behavior to work correctly. i.e. std::locale::global() is=20 > required to > > call setlocale(), but the library may need to call setlocale() > > internally [through a _RW::__rw_setlocale instance]. When=20 > this happens, > > the global locale state [the C/C++ locale set by the setlocale() > > function] will be temporarily overridden behind the users=20 > back, possibly > > resulting in some interesting behavior. >=20 > Right. There's no avoiding it. The best we can do (and what > the test tries to exercise) is that locale::global() doesn't > crash when called simultaneously from multiple threads. >=20 > Martin >=20