Return-Path: X-Original-To: apmail-stdcxx-dev-archive@www.apache.org Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 79674D7B6 for ; Wed, 12 Sep 2012 04:22:24 +0000 (UTC) Received: (qmail 12866 invoked by uid 500); 12 Sep 2012 04:22:23 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 12565 invoked by uid 500); 12 Sep 2012 04:22:17 -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 12252 invoked by uid 99); 12 Sep 2012 04:22:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Sep 2012 04:22:15 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of stefan.teleman@gmail.com designates 209.85.220.182 as permitted sender) Received: from [209.85.220.182] (HELO mail-vc0-f182.google.com) (209.85.220.182) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Sep 2012 04:22:10 +0000 Received: by vcbfw7 with SMTP id fw7so1645774vcb.41 for ; Tue, 11 Sep 2012 21:21:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=/4gkJVK3ng8xHLAP91d3SjeJAkGiZwvJucJ7OVS2CjE=; b=NtKD6dsdHRa4TgFGK9qjt2dhpZ1eyCerXJjXTNpNizE65Tu7MELJWnmQ49rKR2cPny yM04f05Li2uOutfxhf/p6GgKemmuExenozFwM4QKfqFL88wD0QIS5JFJwKZNsnzCJw2+ 6irgXYZYhXkvD0DYdDSl14VTCRKpd5lCVZcM4eiqce7i4q2cxZDFKQkv4LFA0LVMs+X/ cmxAVXvSldctqkGtvenaTUKbQx9T/KkiovVuMHypcOxfgtxsgCnWjsnr+lapGjMyBh+8 nqT1munDHt7w1KooEUB1DJOQ+zJdNn+PKslCYyVWHv/a7D9GFM4zm+ftWfXGC7hzf7+8 1JcA== MIME-Version: 1.0 Received: by 10.220.150.77 with SMTP id x13mr28129632vcv.27.1347423709474; Tue, 11 Sep 2012 21:21:49 -0700 (PDT) Received: by 10.58.29.164 with HTTP; Tue, 11 Sep 2012 21:21:49 -0700 (PDT) In-Reply-To: <504FF10E.8020506@hates.ms> References: <40394653-8FCC-4D04-A108-2C650AF8F95B@hates.ms> <50479CA6.8010306@hates.ms> <50481097.2080307@gmail.com> <50481DDC.6010906@gmail.com> <5048A224.7060402@hates.ms> <5048CC76.5060603@gmail.com> <5049016D.8000902@gmail.com> <504E2440.1060706@gmail.com> <504FE7F9.90102@gmail.com> <504FF10E.8020506@hates.ms> Date: Wed, 12 Sep 2012 00:21:49 -0400 Message-ID: Subject: Re: STDCXX-1056 [was: Re: STDCXX forks] From: Stefan Teleman To: dev@stdcxx.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org On Tue, Sep 11, 2012 at 10:18 PM, Liviu Nicoara wrote: > AFAICT, there are two cases to consider: > > 1. Using STDCXX locale database initializes the __rw_punct_t data in the > first, properly synchronized pass through __rw_get_numpunct. All subsequent > calls use the __rw_punct_t data to construct returned objects. > 2. Using the C library locales does the same in the first pass, via > setlocale and localeconv, but setlocale synchronization is via a per-process > lock. The facet data, once initialized is used just like above. > > I probably missed this in the previous conversation, but did you detect a > race condition in the tests if the facets are simply forwarding to the > private virtual interface? I.e., did you detect that the facet > initialization code is unsafe? I think the facet __rw_punct_t data is safely > initialized in both cases, it's the caching that is done incorrectly. I originally thought so too, but now I'm having doubts. :-) And I haven't tracked it down with 100% accuracy yet. I saw today this comment in src/facet.cpp, line 358: // a per-process array of facet pointers sufficiently large // to hold (pointers to) all standard facets for 8 locales static __rw_facet* std_facet_buf [__rw_facet::_C_last_type * 8]; this leads me to suspect that there is an upper limit of 8 locales + their standard facets. If the locales (and their facets) are being recycled in and out of this 8-limit cache, that would explain the other thing I also noticed (which also answers your question): yes, i have gotten the dreaded strcmp(3C) 'Assertion failed' in 22.locale.numpunct.mt when I test implemented 22.locale.numpunct.mt in a similar way to your tests. which in theory shouldn't happen, but it did. which means that there's something going on with behind-the-scenes facet re-initialization that i haven't found yet. which would partially explain your observation that MT-tests perform much worse with caching than without. this is all investigative stuff for tomorrow. :-) and I agree with Martin that breaking ABI in a minor release is really not an option. I'm trying to find the best way of making these facets thread-safe while inflicting the least horrible performance hit. i will run your tests tomorrow and let you know. :-) --Stefan -- Stefan Teleman KDE e.V. stefan.teleman@gmail.com