This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug sanitizer/59215] tsan: warning in shared_ptr_base.h
- From: "oleg at smolsky dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 20 Nov 2013 18:15:34 +0000
- Subject: [Bug sanitizer/59215] tsan: warning in shared_ptr_base.h
- Auto-submitted: auto-generated
- References: <bug-59215-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59215
--- Comment #9 from Oleg Smolsky <oleg at smolsky dot net> ---
So, let me see if I understand. The case in question is _M_add_ref_lock() :
template<>
inline void
_Sp_counted_base<_S_atomic>::
_M_add_ref_lock()
{
// Perform lock-free add-if-not-zero operation.
_Atomic_word __count = _M_use_count; <==== the read
do
{
if (__count == 0)
__throw_bad_weak_ptr();
// Replace the current counter value with the old value + 1, as
// long as it's not changed meanwhile.
}
while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1,
true, __ATOMIC_ACQ_REL,
__ATOMIC_RELAXED));
}
The read is flagged by TSan because it is non-atomic. So, it seems that no
amount of recompilation is going to work here... unless the recompiled actually
redefines _Atomic_word to an atomic.
Or am I missing something here?