This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug sanitizer/59215] tsan: warning in shared_ptr_base.h


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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]