You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@stdcxx.apache.org by "Farid Zaripov (JIRA)" <ji...@apache.org> on 2008/03/24 17:25:28 UTC

[jira] Created: (STDCXX-792) __rw_locale::_C_manage() uses mutex based __rw_atomic_preincrement() even if platform supports the native atomic operations

__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.2.0, 4.1.4, 4.1.3, 4.1.2
         Environment: All
            Reporter: Farid Zaripov
            Assignee: Farid Zaripov
             Fix For: 4.2.1


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<volatile long>() (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.


[jira] Commented: (STDCXX-792) __rw_locale::_C_manage() uses mutex based __rw_atomic_preincrement() even if platform supports the native atomic operations

Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-792?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581591#action_12581591 ] 

Farid Zaripov commented on STDCXX-792:
--------------------------------------

The proposed patch below:

  ChangeLog:
  STDCXX-792
  * src/locale_body.cpp (_C_manage): Declare static variable ginit as non-volatile, to use the
  non-template version __rw_atomic_preincrement() instead of template version, if available.
  Declare static variable ginit as int instead of long because the all native atomic  functions
  are defined for int type and the overloads for long type just calls overload for int type on
  platforms where sizeof (int) == sizeof (long).

{noformat}
Index: src/locale_body.cpp
===================================================================
--- src/locale_body.cpp	(revision 640425)
+++ src/locale_body.cpp	(working copy)
@@ -805,7 +805,7 @@
 
         if (!global) {
 
-            static volatile long ginit /* = 0 */;
+            static int ginit /* = 0 */;
 
             if (!ginit && 1 == _RWSTD_ATOMIC_PREINCREMENT (ginit, false)) {
                 global  = _C_manage (0, "C");
{noformat}


> __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<volatile long>() (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.


[jira] Commented: (STDCXX-792) __rw_locale::_C_manage() uses mutex based __rw_atomic_preincrement() even if platform supports the native atomic operations

Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-792?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581592#action_12581592 ] 

Farid Zaripov commented on STDCXX-792:
--------------------------------------

Possibly we should declare native __rw_atomic_xxx() functions as accepting the volatile reference, but this is an another issue for 5.0 release due to binary incompatibility of such change.

> __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<volatile long>() (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.


[jira] Resolved: (STDCXX-792) __rw_locale::_C_manage() uses mutex based __rw_atomic_preincrement() even if platform supports the native atomic operations

Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-792?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Farid Zaripov resolved STDCXX-792.
----------------------------------

    Resolution: Fixed

Fixed thus: http://svn.apache.org/viewvc?rev=640746&view=rev

Will be closed after merging the changes in 4.2.x branch.

> __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<volatile long>() (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.


[jira] Commented: (STDCXX-792) __rw_locale::_C_manage() uses mutex based __rw_atomic_preincrement() even if platform supports the native atomic operations

Posted by "Martin Sebor (JIRA)" <ji...@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<volatile long>() (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.


[jira] Closed: (STDCXX-792) __rw_locale::_C_manage() uses mutex based __rw_atomic_preincrement() even if platform supports the native atomic operations

Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-792?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Farid Zaripov closed STDCXX-792.
--------------------------------


Merged in 4.2.x branch thus: http://svn.apache.org/viewvc?view=rev&revision=648752

> __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<volatile long>() (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.


[jira] Updated: (STDCXX-792) __rw_locale::_C_manage() uses mutex based __rw_atomic_preincrement() even if platform supports the native atomic operations

Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-792?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Farid Zaripov updated STDCXX-792:
---------------------------------

    Patch Info: [Patch Available]

> __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<volatile long>() (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.