This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug sanitizer/59215] New: 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 16:38:28 +0000
- Subject: [Bug sanitizer/59215] New: tsan: warning in shared_ptr_base.h
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59215
Bug ID: 59215
Summary: tsan: warning in shared_ptr_base.h
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: sanitizer
Assignee: unassigned at gcc dot gnu.org
Reporter: oleg at smolsky dot net
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
I just got what appears to be a false positive in GCC's own implementation of
shared_ptr ref counts:
Read of size 4 by thread T21:
#0 _M_add_ref_lock ...gcc/include/c++/4.8.x-google/bits/shared_ptr_base.h:236
Previous atomic write of size 4 by main thread:
#0 __tsan_atomic32_fetch_add ??:0 (libtsan.so.0+0x00000000d3e5)
#1 __exchange_and_add_dispatch
...gcc/include/c++/4.8.x-google/ext/atomicity.h:49
....
The atomic write is obvious - it's an "up ref". The read, however, should have
just worked as the variable is (well, is supposed to be) atomic.
I don't get it... is the tool missing the atomic manipulation? Or is the
library missing the correct annotation? I'm leaning towards the latter:
in ...gcc/include/c++/4.8.x-google/x86_64-unknown-linux/bits/atomic_word.h
typedef int _Atomic_word;
Should this be std::atomic<int> ?