Patchwork fix libstdc++/59215

login
register
mail settings
Submitter Jonathan Wakely
Date March 11, 2014, 7:41 p.m.
Message ID <20140311194111.GA17337@redhat.com>
Download mbox | patch
Permalink /patch/329208/
State New
Headers show

Comments

Jonathan Wakely - March 11, 2014, 7:41 p.m.
On 27/01/14 17:58 +0000, Jonathan Wakely wrote:
>This fixes a tsan warning in shared_ptr by replacing the non-atomic
>load with a call to _M_get_use_count() which does a relaxed atomic
>load.
>
>Tested x86_64-linux, committed to trunk. Will commit to 4.8 soon too.

Here's the commit to the 4.8 branch.
commit 3be0a51522649213782c2bda37ceaf1454840275
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Mar 11 19:27:53 2014 +0000

    2014-03-11  Jonathan Wakely  <jwakely@redhat.com>
    
    	Backport from mainline.
    	2014-01-27  Jonathan Wakely  <jwakely@redhat.com>
    
    	PR libstdc++/59215
    	* include/bits/shared_ptr_base.h
    	(_Sp_counted_base<_S_atomic>::_M_add_ref_lock()): Use relaxed atomic
    	load.

Patch

diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index 9dcefa2..e661b65 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -233,7 +233,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _M_add_ref_lock()
     {
       // Perform lock-free add-if-not-zero operation.
-      _Atomic_word __count = _M_use_count;
+      _Atomic_word __count = _M_get_use_count();
       do
 	{
 	  if (__count == 0)