stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Travis Vitek" <tvi...@quovadx.com>
Subject RE: [PATCH] set id of user locale facets safely
Date Fri, 28 Sep 2007 23:33:58 GMT


Martin Sebor wrote:
>
>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.
>

I do not believe that we have a test to exercise this. I will try to
create one Monday.

>
>The _C_init() function is (should be) only called on user-defined
>specializations of facets (such as ctype<UserChar> 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.

Yes, this is a potential problem for non-standard facets only.


Mime
View raw message