From stdcxx-dev-return-5268-apmail-incubator-stdcxx-dev-archive=incubator.apache.org@incubator.apache.org Fri Sep 28 22:47:14 2007 Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 53128 invoked from network); 28 Sep 2007 22:47:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Sep 2007 22:47:14 -0000 Received: (qmail 32198 invoked by uid 500); 28 Sep 2007 22:47:04 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 32177 invoked by uid 500); 28 Sep 2007 22:47:04 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 32166 invoked by uid 99); 28 Sep 2007 22:47:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2007 15:47:04 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.quovadx.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2007 22:47:06 +0000 Received: from qxvcexch01.ad.quovadx.com ([192.168.170.59]) by moroha.quovadx.com (8.13.6/8.13.6) with ESMTP id l8SMk3Lx014024 for ; Fri, 28 Sep 2007 22:46:03 GMT Received: from [10.70.3.113] ([10.70.3.113]) by qxvcexch01.ad.quovadx.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 28 Sep 2007 16:46:29 -0600 Message-ID: <46FD8455.8080801@roguewave.com> Date: Fri, 28 Sep 2007 16:46:45 -0600 From: Martin Sebor Organization: Rogue Wave Software, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4 MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: Re: [PATCH] set id of user locale facets safely References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 28 Sep 2007 22:46:29.0200 (UTC) FILETIME=[68979500:01C80221] X-Virus-Checked: Checked by ClamAV on apache.org Travis Vitek wrote: > > The method for initializing the facet id is not currently thread safe. > > If a thread enters __rw_facet_id::_C_init() and is preempted after > checking _C_id, a second thread can do the same check, increment the > static counter, assign the facet id, and then return. The preempted > thread would increment the static counter again, assign a new value to > the facet id. > > This could cause has_facet, use_facet, or locale constructor to fail > unexpectedly. I'm fine with the patch but I'm curious if we have tests that fail as result of this? The standard facets all have their own unique unchanged ids that are assigned when the facet is constructed by the library. The _C_init() function is (should be) only called on user-defined specializations of facets (such as ctype or PhoneFacet). Initialization of such facets should, of course, be thread-safe as well but I don't think we have tests that exercise it. > > > 2007-09-28 Travis Vitek > > * facet.cpp (_C_init): initialize facet id in a threadsafe > manner. > > > > Index: facet.cpp > =================================================================== > --- facet.cpp (revision 578875) > +++ facet.cpp (working copy) > @@ -597,17 +597,15 @@ > > _RWSTD_SIZE_T __rw_facet_id::_C_init () const > { > + _RWSTD_MT_STATIC_GUARD(_RW::__rw_facet_id); This is missing a space before the paren. Martin