[patch] fix libstdc++/59215
Jonathan Wakely
jwakely@redhat.com
Tue Mar 11 21:08:00 GMT 2014
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.
-------------- next part --------------
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.
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)
More information about the Gcc-patches
mailing list