From issues-return-820-apmail-stdcxx-issues-archive=stdcxx.apache.org@stdcxx.apache.org Tue Mar 25 03:43:31 2008 Return-Path: Delivered-To: apmail-stdcxx-issues-archive@locus.apache.org Received: (qmail 14820 invoked from network); 25 Mar 2008 03:43:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Mar 2008 03:43:31 -0000 Received: (qmail 27020 invoked by uid 500); 25 Mar 2008 03:43:30 -0000 Delivered-To: apmail-stdcxx-issues-archive@stdcxx.apache.org Received: (qmail 27003 invoked by uid 500); 25 Mar 2008 03:43:30 -0000 Mailing-List: contact issues-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 issues@stdcxx.apache.org Received: (qmail 26994 invoked by uid 99); 25 Mar 2008 03:43:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Mar 2008 20:43:30 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Mar 2008 03:42:59 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id B092B234C0AE for ; Mon, 24 Mar 2008 20:41:26 -0700 (PDT) Message-ID: <44637935.1206416486722.JavaMail.jira@brutus> Date: Mon, 24 Mar 2008 20:41:26 -0700 (PDT) From: "Martin Sebor (JIRA)" To: issues@stdcxx.apache.org Subject: [jira] Commented: (STDCXX-792) __rw_locale::_C_manage() uses mutex based __rw_atomic_preincrement() even if platform supports the native atomic operations In-Reply-To: <393709672.1206375928283.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/STDCXX-792?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581767#action_12581767 ] Martin Sebor commented on STDCXX-792: ------------------------------------- I don't think the patch is safe. In particular, without the {{volatile}} qualifier an optimizer would be free to turn the {{while}} loop below into an infinite loop. {noformat} 808 static volatile long ginit /* = 0 */; 809 810 if (!ginit && 1 == _RWSTD_ATOMIC_PREINCREMENT (ginit, false)) { 811 global = _C_manage (0, "C"); 812 ginit += 1000; 813 } 814 else { 815 while (ginit < 1000); 816 } {noformat} I agree that we should change the {{__rw_atomic_xxx()}} functions to take a {{volatile}}-qualified argument and also that such a change would probably be binary incompatible. What we might want to do in the meantime is either cast away the {{volatile}} qualifier in the invocation of the {{_RWSTD_ATOMIC_PREINCREMENT()}} macro or change the definition of the macro itself to this effect. > __rw_locale::_C_manage() uses mutex based __rw_atomic_preincrement() even if platform supports the native atomic operations > --------------------------------------------------------------------------------------------------------------------------- > > Key: STDCXX-792 > URL: https://issues.apache.org/jira/browse/STDCXX-792 > Project: C++ Standard Library > Issue Type: Bug > Components: 22. Localization > Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0 > Environment: All > Reporter: Farid Zaripov > Assignee: Farid Zaripov > Fix For: 4.2.1 > > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > In __rw_locale::_C_manage() (src/locale_body.cpp, line 808), the static variable ginit declared as volatile, but __rw_atomic_preincrement() functions, which are implemented using atomic operations, accepting the non-volatile reference in parameter list. As a result the template version __rw_atomic_preincrement() (which is implemented using mutex object) is used. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.