[Bug sanitizer/101978] New: thread sanitizer false positive when smart pointers
ispavlick at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Aug 19 14:31:54 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101978
Bug ID: 101978
Summary: thread sanitizer false positive when smart pointers
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: sanitizer
Assignee: unassigned at gcc dot gnu.org
Reporter: ispavlick at gmail dot com
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, marxin at gcc dot gnu.org
Target Milestone: ---
When it is compiled with clang then no warnings are displayed (from sanitizer).
#include <mutex>
#include <thread>
#include <chrono>
#include <condition_variable>
#include <queue>
#include <memory>
using namespace std;
struct Mes {
int data = 0;
bool processed = false;
};
struct Test {
mutex mtx;
condition_variable cv;
queue<weak_ptr<Mes>> mes_queue;
int read();
bool check();
} t;
int Test::read() {
auto sh_ptr = make_shared<Mes>();
unique_lock lck{mtx};
mes_queue.push(sh_ptr);
while (! cv.wait_for(lck, 1s, [&sh_ptr](){
return sh_ptr->processed == true;}) && true);
return sh_ptr->data;
}
bool Test::check() {
unique_lock lck{mtx};
bool ret = mes_queue.size();
while (mes_queue.size()) {
if (shared_ptr<Mes> mes = mes_queue.front().lock()) {
mes->data = 5;
mes->processed = true;
}
mes_queue.pop();
}
cv.notify_all();
return ret;
}
void read_th() {
while (true) {
t.read();
this_thread::sleep_for(200ms);
}
}
void check_th() {
while (true) {
t.check();
this_thread::sleep_for(200ms);
}
}
int main() {
jthread tr{read_th};
jthread tc{check_th};
}
$ g++ -pthread -std=c++20 -fsanitize=thread test.cc
$ ./a.out
==================
WARNING: ThreadSanitizer: double lock of a mutex (pid=76697)
#0 pthread_mutex_lock
/build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4250
(libtsan.so.0+0x54b6a)
#1 __gthread_mutex_lock(pthread_mutex_t*) <null> (a.out+0x2df5)
#2 std::mutex::lock() <null> (a.out+0x2e7a)
#3 std::unique_lock<std::mutex>::lock() <null> (a.out+0x56f5)
#4 std::unique_lock<std::mutex>::unique_lock(std::mutex&) <null>
(a.out+0x4a32)
#5 Test::check() <null> (a.out+0x2628)
#6 check_th() <null> (a.out+0x27d7)
#7 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#8 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#9 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#10 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#11 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#12 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Location is global 't' of size 168 at 0x562d5860c1c0 (a.out+0x0000000111c0)
Mutex M10 (0x562d5860c1c0) created at:
#0 pthread_mutex_lock
/build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4250
(libtsan.so.0+0x54b6a)
#1 __gthread_mutex_lock(pthread_mutex_t*) <null> (a.out+0x2df5)
#2 std::mutex::lock() <null> (a.out+0x2e7a)
#3 std::unique_lock<std::mutex>::lock() <null> (a.out+0x56f5)
#4 std::unique_lock<std::mutex>::unique_lock(std::mutex&) <null>
(a.out+0x4a32)
#5 Test::read() <null> (a.out+0x24d0)
#6 read_th() <null> (a.out+0x277a)
#7 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#8 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#9 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#10 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#11 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#12 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
SUMMARY: ThreadSanitizer: double lock of a mutex (/tmp/a.out+0x2df5) in
__gthread_mutex_lock(pthread_mutex_t*)
==================
==================
WARNING: ThreadSanitizer: data race (pid=76697)
Read of size 8 at 0x562d5860c248 by thread T2 (mutexes: write M10):
#0 std::operator-(std::_Deque_iterator<std::weak_ptr<Mes>,
std::weak_ptr<Mes>&, std::weak_ptr<Mes>*> const&,
std::_Deque_iterator<std::weak_ptr<Mes>, std::weak_ptr<Mes>&,
std::weak_ptr<Mes>*> const&) <null> (a.out+0x6ba3)
#1 std::deque<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::size() const <null> (a.out+0x5cad)
#2 std::queue<std::weak_ptr<Mes>, std::deque<std::weak_ptr<Mes>,
std::allocator<std::weak_ptr<Mes> > > >::size() const <null> (a.out+0x4c20)
#3 Test::check() <null> (a.out+0x2638)
#4 check_th() <null> (a.out+0x27d7)
#5 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#6 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#7 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#8 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#9 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#10 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Previous write of size 8 at 0x562d5860c248 by thread T1 (mutexes: write M10):
#0 std::weak_ptr<Mes>& std::deque<std::weak_ptr<Mes>,
std::allocator<std::weak_ptr<Mes> > >::emplace_back<std::weak_ptr<Mes>
>(std::weak_ptr<Mes>&&) <null> (a.out+0x6896)
#1 std::deque<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::push_back(std::weak_ptr<Mes>&&) <null> (a.out+0x5992)
#2 std::queue<std::weak_ptr<Mes>, std::deque<std::weak_ptr<Mes>,
std::allocator<std::weak_ptr<Mes> > > >::push(std::weak_ptr<Mes>&&) <null>
(a.out+0x4b77)
#3 Test::read() <null> (a.out+0x24fa)
#4 read_th() <null> (a.out+0x277a)
#5 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#6 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#7 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#8 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#9 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#10 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Location is global 't' of size 168 at 0x562d5860c1c0 (a.out+0x000000011248)
Mutex M10 (0x562d5860c1c0) created at:
#0 pthread_mutex_lock
/build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4250
(libtsan.so.0+0x54b6a)
#1 __gthread_mutex_lock(pthread_mutex_t*) <null> (a.out+0x2df5)
#2 std::mutex::lock() <null> (a.out+0x2e7a)
#3 std::unique_lock<std::mutex>::lock() <null> (a.out+0x56f5)
#4 std::unique_lock<std::mutex>::unique_lock(std::mutex&) <null>
(a.out+0x4a32)
#5 Test::read() <null> (a.out+0x24d0)
#6 read_th() <null> (a.out+0x277a)
#7 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#8 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#9 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#10 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#11 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#12 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Thread T2 (tid=76700, running) created by main thread at:
#0 pthread_create
/build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:969
(libtsan.so.0+0x61c3a)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
std::default_delete<std::thread::_State> >, void (*)())
/build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663
(libstdc++.so.6+0xd36aa)
#2 std::thread std::jthread::_S_create<void (&)()>(std::stop_source&, void
(&)()) <null> (a.out+0x5ef2)
#3 std::jthread::jthread<void (&)(), , void>(void (&)()) <null>
(a.out+0x4d9b)
#4 main <null> (a.out+0x2851)
Thread T1 (tid=76699, running) created by main thread at:
#0 pthread_create
/build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:969
(libtsan.so.0+0x61c3a)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
std::default_delete<std::thread::_State> >, void (*)())
/build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663
(libstdc++.so.6+0xd36aa)
#2 std::thread std::jthread::_S_create<void (&)()>(std::stop_source&, void
(&)()) <null> (a.out+0x5ef2)
#3 std::jthread::jthread<void (&)(), , void>(void (&)()) <null>
(a.out+0x4d9b)
#4 main <null> (a.out+0x283b)
SUMMARY: ThreadSanitizer: data race (/tmp/a.out+0x6ba3) in
std::operator-(std::_Deque_iterator<std::weak_ptr<Mes>, std::weak_ptr<Mes>&,
std::weak_ptr<Mes>*> const&, std::_Deque_iterator<std::weak_ptr<Mes>,
std::weak_ptr<Mes>&, std::weak_ptr<Mes>*> const&)
==================
==================
WARNING: ThreadSanitizer: data race (pid=76697)
Read of size 8 at 0x7b5000000008 by thread T2 (mutexes: write M10):
#0
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count(std::__weak_count<(__gnu_cxx::_Lock_policy)2>
const&, std::nothrow_t) <null> (a.out+0x7b82)
#1 std::__shared_ptr<Mes,
(__gnu_cxx::_Lock_policy)2>::__shared_ptr(std::__weak_ptr<Mes,
(__gnu_cxx::_Lock_policy)2> const&, std::nothrow_t) <null> (a.out+0x6c8b)
#2 std::shared_ptr<Mes>::shared_ptr(std::weak_ptr<Mes> const&,
std::nothrow_t) <null> (a.out+0x5d5c)
#3 std::weak_ptr<Mes>::lock() const <null> (a.out+0x4c9a)
#4 Test::check() <null> (a.out+0x2668)
#5 check_th() <null> (a.out+0x27d7)
#6 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#7 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#8 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#9 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#10 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#11 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Previous write of size 8 at 0x7b5000000008 by thread T1 (mutexes: write M10):
#0
std::__weak_count<(__gnu_cxx::_Lock_policy)2>::__weak_count(std::__weak_count<(__gnu_cxx::_Lock_policy)2>&&)
<null> (a.out+0x8c0d)
#1 std::__weak_ptr<Mes,
(__gnu_cxx::_Lock_policy)2>::__weak_ptr(std::__weak_ptr<Mes,
(__gnu_cxx::_Lock_policy)2>&&) <null> (a.out+0x8387)
#2 std::weak_ptr<Mes>::weak_ptr(std::weak_ptr<Mes>&&) <null> (a.out+0x75f0)
#3 decltype (::new ((void*)(0))
std::weak_ptr<Mes>((declval<std::weak_ptr<Mes> >)()))
std::construct_at<std::weak_ptr<Mes>, std::weak_ptr<Mes> >(std::weak_ptr<Mes>*,
std::weak_ptr<Mes>&&) <null> (a.out+0x7645)
#4 void std::allocator_traits<std::allocator<std::weak_ptr<Mes> >
>::construct<std::weak_ptr<Mes>, std::weak_ptr<Mes>
>(std::allocator<std::weak_ptr<Mes> >&, std::weak_ptr<Mes>*,
std::weak_ptr<Mes>&&) <null> (a.out+0x7694)
#5 std::weak_ptr<Mes>& std::deque<std::weak_ptr<Mes>,
std::allocator<std::weak_ptr<Mes> > >::emplace_back<std::weak_ptr<Mes>
>(std::weak_ptr<Mes>&&) <null> (a.out+0x686a)
#6 std::deque<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::push_back(std::weak_ptr<Mes>&&) <null> (a.out+0x5992)
#7 std::queue<std::weak_ptr<Mes>, std::deque<std::weak_ptr<Mes>,
std::allocator<std::weak_ptr<Mes> > > >::push(std::weak_ptr<Mes>&&) <null>
(a.out+0x4b77)
#8 Test::read() <null> (a.out+0x24fa)
#9 read_th() <null> (a.out+0x277a)
#10 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#11 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#12 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#13 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#14 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#15 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Location is heap block of size 512 at 0x7b5000000000 allocated by main
thread:
#0 operator new(unsigned long)
/build/gcc/src/gcc/libsanitizer/tsan/tsan_new_delete.cpp:64
(libtsan.so.0+0x91824)
#1 __gnu_cxx::new_allocator<std::weak_ptr<Mes> >::allocate(unsigned long,
void const*) <null> (a.out+0x999e)
#2 std::allocator_traits<std::allocator<std::weak_ptr<Mes> >
>::allocate(std::allocator<std::weak_ptr<Mes> >&, unsigned long) <null>
(a.out+0x87d8)
#3 std::_Deque_base<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::_M_allocate_node() <null> (a.out+0x804c)
#4 std::_Deque_base<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::_M_create_nodes(std::weak_ptr<Mes>**, std::weak_ptr<Mes>**) <null>
(a.out+0x71c6)
#5 std::_Deque_base<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::_M_initialize_map(unsigned long) <null> (a.out+0x61d5)
#6 std::_Deque_base<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::_Deque_base() <null> (a.out+0x53b3)
#7 std::deque<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::deque() <null> (a.out+0x47ca)
#8 std::queue<std::weak_ptr<Mes>, std::deque<std::weak_ptr<Mes>,
std::allocator<std::weak_ptr<Mes> > > >::queue<std::deque<std::weak_ptr<Mes>,
std::allocator<std::weak_ptr<Mes> > >, void>() <null> (a.out+0x4874)
#9 Test::Test() <null> (a.out+0x3eec)
#10 __static_initialization_and_destruction_0(int, int) <null>
(a.out+0x2a52)
#11 _GLOBAL__sub_I_t <null> (a.out+0x2ab4)
#12 __libc_csu_init <null> (a.out+0xa64c)
Mutex M10 (0x562d5860c1c0) created at:
#0 pthread_mutex_lock
/build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4250
(libtsan.so.0+0x54b6a)
#1 __gthread_mutex_lock(pthread_mutex_t*) <null> (a.out+0x2df5)
#2 std::mutex::lock() <null> (a.out+0x2e7a)
#3 std::unique_lock<std::mutex>::lock() <null> (a.out+0x56f5)
#4 std::unique_lock<std::mutex>::unique_lock(std::mutex&) <null>
(a.out+0x4a32)
#5 Test::read() <null> (a.out+0x24d0)
#6 read_th() <null> (a.out+0x277a)
#7 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#8 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#9 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#10 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#11 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#12 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Thread T2 (tid=76700, running) created by main thread at:
#0 pthread_create
/build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:969
(libtsan.so.0+0x61c3a)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
std::default_delete<std::thread::_State> >, void (*)())
/build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663
(libstdc++.so.6+0xd36aa)
#2 std::thread std::jthread::_S_create<void (&)()>(std::stop_source&, void
(&)()) <null> (a.out+0x5ef2)
#3 std::jthread::jthread<void (&)(), , void>(void (&)()) <null>
(a.out+0x4d9b)
#4 main <null> (a.out+0x2851)
Thread T1 (tid=76699, running) created by main thread at:
#0 pthread_create
/build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:969
(libtsan.so.0+0x61c3a)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
std::default_delete<std::thread::_State> >, void (*)())
/build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663
(libstdc++.so.6+0xd36aa)
#2 std::thread std::jthread::_S_create<void (&)()>(std::stop_source&, void
(&)()) <null> (a.out+0x5ef2)
#3 std::jthread::jthread<void (&)(), , void>(void (&)()) <null>
(a.out+0x4d9b)
#4 main <null> (a.out+0x283b)
SUMMARY: ThreadSanitizer: data race (/tmp/a.out+0x7b82) in
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count(std::__weak_count<(__gnu_cxx::_Lock_policy)2>
const&, std::nothrow_t)
==================
==================
WARNING: ThreadSanitizer: data race (pid=76697)
Atomic read of size 4 at 0x7b0800001028 by thread T2 (mutexes: write M10):
#0 __tsan_atomic32_load
/build/gcc/src/gcc/libsanitizer/tsan/tsan_interface_atomic.cpp:534
(libtsan.so.0+0x81eaf)
#1 std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_get_use_count()
const <null> (a.out+0x473f)
#2
std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_add_ref_lock_nothrow()
<null> (a.out+0x3d31)
#3
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count(std::__weak_count<(__gnu_cxx::_Lock_policy)2>
const&, std::nothrow_t) <null> (a.out+0x7bcf)
#4 std::__shared_ptr<Mes,
(__gnu_cxx::_Lock_policy)2>::__shared_ptr(std::__weak_ptr<Mes,
(__gnu_cxx::_Lock_policy)2> const&, std::nothrow_t) <null> (a.out+0x6c8b)
#5 std::shared_ptr<Mes>::shared_ptr(std::weak_ptr<Mes> const&,
std::nothrow_t) <null> (a.out+0x5d5c)
#6 std::weak_ptr<Mes>::lock() const <null> (a.out+0x4c9a)
#7 Test::check() <null> (a.out+0x2668)
#8 check_th() <null> (a.out+0x27d7)
#9 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#10 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#11 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#12 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#13 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#14 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Previous write of size 8 at 0x7b0800001028 by thread T1:
#0 operator new(unsigned long)
/build/gcc/src/gcc/libsanitizer/tsan/tsan_new_delete.cpp:64
(libtsan.so.0+0x91824)
#1 __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long,
void const*) <null> (a.out+0x9c51)
#2 std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >
>::allocate(std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) <null>
(a.out+0x943a)
#3 std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> > >
std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >
>(std::allocator<std::_Sp_counted_ptr_inplace<Mes, std::allocator<Mes>,
(__gnu_cxx::_Lock_policy)2> >&) <null> (a.out+0x88dc)
#4 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<Mes,
std::allocator<Mes>>(Mes*&, std::_Sp_alloc_shared_tag<std::allocator<Mes> >)
<null> (a.out+0x8215)
#5 std::__shared_ptr<Mes,
(__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<Mes>>(std::_Sp_alloc_shared_tag<std::allocator<Mes>
>) <null> (a.out+0x74b8)
#6
std::shared_ptr<Mes>::shared_ptr<std::allocator<Mes>>(std::_Sp_alloc_shared_tag<std::allocator<Mes>
>) <null> (a.out+0x6739)
#7 std::shared_ptr<Mes> std::allocate_shared<Mes,
std::allocator<Mes>>(std::allocator<Mes> const&) <null> (a.out+0x5646)
#8 std::shared_ptr<Mes> std::make_shared<Mes>() <null> (a.out+0x497c)
#9 Test::read() <null> (a.out+0x24bd)
#10 read_th() <null> (a.out+0x277a)
#11 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#12 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#13 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#14 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#15 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#16 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Location is heap block of size 24 at 0x7b0800001020 allocated by thread T1:
#0 operator new(unsigned long)
/build/gcc/src/gcc/libsanitizer/tsan/tsan_new_delete.cpp:64
(libtsan.so.0+0x91824)
#1 __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long,
void const*) <null> (a.out+0x9c51)
#2 std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >
>::allocate(std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) <null>
(a.out+0x943a)
#3 std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> > >
std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >
>(std::allocator<std::_Sp_counted_ptr_inplace<Mes, std::allocator<Mes>,
(__gnu_cxx::_Lock_policy)2> >&) <null> (a.out+0x88dc)
#4 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<Mes,
std::allocator<Mes>>(Mes*&, std::_Sp_alloc_shared_tag<std::allocator<Mes> >)
<null> (a.out+0x8215)
#5 std::__shared_ptr<Mes,
(__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<Mes>>(std::_Sp_alloc_shared_tag<std::allocator<Mes>
>) <null> (a.out+0x74b8)
#6
std::shared_ptr<Mes>::shared_ptr<std::allocator<Mes>>(std::_Sp_alloc_shared_tag<std::allocator<Mes>
>) <null> (a.out+0x6739)
#7 std::shared_ptr<Mes> std::allocate_shared<Mes,
std::allocator<Mes>>(std::allocator<Mes> const&) <null> (a.out+0x5646)
#8 std::shared_ptr<Mes> std::make_shared<Mes>() <null> (a.out+0x497c)
#9 Test::read() <null> (a.out+0x24bd)
#10 read_th() <null> (a.out+0x277a)
#11 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#12 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#13 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#14 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#15 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#16 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Mutex M10 (0x562d5860c1c0) created at:
#0 pthread_mutex_lock
/build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4250
(libtsan.so.0+0x54b6a)
#1 __gthread_mutex_lock(pthread_mutex_t*) <null> (a.out+0x2df5)
#2 std::mutex::lock() <null> (a.out+0x2e7a)
#3 std::unique_lock<std::mutex>::lock() <null> (a.out+0x56f5)
#4 std::unique_lock<std::mutex>::unique_lock(std::mutex&) <null>
(a.out+0x4a32)
#5 Test::read() <null> (a.out+0x24d0)
#6 read_th() <null> (a.out+0x277a)
#7 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#8 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#9 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#10 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#11 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#12 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Thread T2 (tid=76700, running) created by main thread at:
#0 pthread_create
/build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:969
(libtsan.so.0+0x61c3a)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
std::default_delete<std::thread::_State> >, void (*)())
/build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663
(libstdc++.so.6+0xd36aa)
#2 std::thread std::jthread::_S_create<void (&)()>(std::stop_source&, void
(&)()) <null> (a.out+0x5ef2)
#3 std::jthread::jthread<void (&)(), , void>(void (&)()) <null>
(a.out+0x4d9b)
#4 main <null> (a.out+0x2851)
Thread T1 (tid=76699, running) created by main thread at:
#0 pthread_create
/build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:969
(libtsan.so.0+0x61c3a)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
std::default_delete<std::thread::_State> >, void (*)())
/build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663
(libstdc++.so.6+0xd36aa)
#2 std::thread std::jthread::_S_create<void (&)()>(std::stop_source&, void
(&)()) <null> (a.out+0x5ef2)
#3 std::jthread::jthread<void (&)(), , void>(void (&)()) <null>
(a.out+0x4d9b)
#4 main <null> (a.out+0x283b)
SUMMARY: ThreadSanitizer: data race (/tmp/a.out+0x473f) in
std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_get_use_count() const
==================
==================
WARNING: ThreadSanitizer: data race (pid=76697)
Read of size 8 at 0x7b5000000000 by thread T2 (mutexes: write M10):
#0 std::__shared_ptr<Mes,
(__gnu_cxx::_Lock_policy)2>::__shared_ptr(std::__weak_ptr<Mes,
(__gnu_cxx::_Lock_policy)2> const&, std::nothrow_t) <null> (a.out+0x6cac)
#1 std::shared_ptr<Mes>::shared_ptr(std::weak_ptr<Mes> const&,
std::nothrow_t) <null> (a.out+0x5d5c)
#2 std::weak_ptr<Mes>::lock() const <null> (a.out+0x4c9a)
#3 Test::check() <null> (a.out+0x2668)
#4 check_th() <null> (a.out+0x27d7)
#5 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#6 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#7 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#8 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#9 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#10 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Previous write of size 8 at 0x7b5000000000 by thread T1 (mutexes: write M10):
#0 std::__weak_ptr<Mes,
(__gnu_cxx::_Lock_policy)2>::__weak_ptr(std::__weak_ptr<Mes,
(__gnu_cxx::_Lock_policy)2>&&) <null> (a.out+0x835d)
#1 std::weak_ptr<Mes>::weak_ptr(std::weak_ptr<Mes>&&) <null> (a.out+0x75f0)
#2 decltype (::new ((void*)(0))
std::weak_ptr<Mes>((declval<std::weak_ptr<Mes> >)()))
std::construct_at<std::weak_ptr<Mes>, std::weak_ptr<Mes> >(std::weak_ptr<Mes>*,
std::weak_ptr<Mes>&&) <null> (a.out+0x7645)
#3 void std::allocator_traits<std::allocator<std::weak_ptr<Mes> >
>::construct<std::weak_ptr<Mes>, std::weak_ptr<Mes>
>(std::allocator<std::weak_ptr<Mes> >&, std::weak_ptr<Mes>*,
std::weak_ptr<Mes>&&) <null> (a.out+0x7694)
#4 std::weak_ptr<Mes>& std::deque<std::weak_ptr<Mes>,
std::allocator<std::weak_ptr<Mes> > >::emplace_back<std::weak_ptr<Mes>
>(std::weak_ptr<Mes>&&) <null> (a.out+0x686a)
#5 std::deque<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::push_back(std::weak_ptr<Mes>&&) <null> (a.out+0x5992)
#6 std::queue<std::weak_ptr<Mes>, std::deque<std::weak_ptr<Mes>,
std::allocator<std::weak_ptr<Mes> > > >::push(std::weak_ptr<Mes>&&) <null>
(a.out+0x4b77)
#7 Test::read() <null> (a.out+0x24fa)
#8 read_th() <null> (a.out+0x277a)
#9 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#10 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#11 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#12 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#13 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#14 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Location is heap block of size 512 at 0x7b5000000000 allocated by main
thread:
#0 operator new(unsigned long)
/build/gcc/src/gcc/libsanitizer/tsan/tsan_new_delete.cpp:64
(libtsan.so.0+0x91824)
#1 __gnu_cxx::new_allocator<std::weak_ptr<Mes> >::allocate(unsigned long,
void const*) <null> (a.out+0x999e)
#2 std::allocator_traits<std::allocator<std::weak_ptr<Mes> >
>::allocate(std::allocator<std::weak_ptr<Mes> >&, unsigned long) <null>
(a.out+0x87d8)
#3 std::_Deque_base<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::_M_allocate_node() <null> (a.out+0x804c)
#4 std::_Deque_base<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::_M_create_nodes(std::weak_ptr<Mes>**, std::weak_ptr<Mes>**) <null>
(a.out+0x71c6)
#5 std::_Deque_base<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::_M_initialize_map(unsigned long) <null> (a.out+0x61d5)
#6 std::_Deque_base<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::_Deque_base() <null> (a.out+0x53b3)
#7 std::deque<std::weak_ptr<Mes>, std::allocator<std::weak_ptr<Mes> >
>::deque() <null> (a.out+0x47ca)
#8 std::queue<std::weak_ptr<Mes>, std::deque<std::weak_ptr<Mes>,
std::allocator<std::weak_ptr<Mes> > > >::queue<std::deque<std::weak_ptr<Mes>,
std::allocator<std::weak_ptr<Mes> > >, void>() <null> (a.out+0x4874)
#9 Test::Test() <null> (a.out+0x3eec)
#10 __static_initialization_and_destruction_0(int, int) <null>
(a.out+0x2a52)
#11 _GLOBAL__sub_I_t <null> (a.out+0x2ab4)
#12 __libc_csu_init <null> (a.out+0xa64c)
Mutex M10 (0x562d5860c1c0) created at:
#0 pthread_mutex_lock
/build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4250
(libtsan.so.0+0x54b6a)
#1 __gthread_mutex_lock(pthread_mutex_t*) <null> (a.out+0x2df5)
#2 std::mutex::lock() <null> (a.out+0x2e7a)
#3 std::unique_lock<std::mutex>::lock() <null> (a.out+0x56f5)
#4 std::unique_lock<std::mutex>::unique_lock(std::mutex&) <null>
(a.out+0x4a32)
#5 Test::read() <null> (a.out+0x24d0)
#6 read_th() <null> (a.out+0x277a)
#7 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#8 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#9 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#10 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#11 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#12 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Thread T2 (tid=76700, running) created by main thread at:
#0 pthread_create
/build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:969
(libtsan.so.0+0x61c3a)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
std::default_delete<std::thread::_State> >, void (*)())
/build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663
(libstdc++.so.6+0xd36aa)
#2 std::thread std::jthread::_S_create<void (&)()>(std::stop_source&, void
(&)()) <null> (a.out+0x5ef2)
#3 std::jthread::jthread<void (&)(), , void>(void (&)()) <null>
(a.out+0x4d9b)
#4 main <null> (a.out+0x2851)
Thread T1 (tid=76699, running) created by main thread at:
#0 pthread_create
/build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:969
(libtsan.so.0+0x61c3a)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
std::default_delete<std::thread::_State> >, void (*)())
/build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663
(libstdc++.so.6+0xd36aa)
#2 std::thread std::jthread::_S_create<void (&)()>(std::stop_source&, void
(&)()) <null> (a.out+0x5ef2)
#3 std::jthread::jthread<void (&)(), , void>(void (&)()) <null>
(a.out+0x4d9b)
#4 main <null> (a.out+0x283b)
SUMMARY: ThreadSanitizer: data race (/tmp/a.out+0x6cac) in
std::__shared_ptr<Mes,
(__gnu_cxx::_Lock_policy)2>::__shared_ptr(std::__weak_ptr<Mes,
(__gnu_cxx::_Lock_policy)2> const&, std::nothrow_t)
==================
==================
WARNING: ThreadSanitizer: data race (pid=76697)
Write of size 4 at 0x7b0800001030 by thread T2 (mutexes: write M10):
#0 Test::check() <null> (a.out+0x2692)
#1 check_th() <null> (a.out+0x27d7)
#2 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#3 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#4 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#5 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#6 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#7 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Previous write of size 8 at 0x7b0800001030 by thread T1:
#0 operator new(unsigned long)
/build/gcc/src/gcc/libsanitizer/tsan/tsan_new_delete.cpp:64
(libtsan.so.0+0x91824)
#1 __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long,
void const*) <null> (a.out+0x9c51)
#2 std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >
>::allocate(std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) <null>
(a.out+0x943a)
#3 std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> > >
std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >
>(std::allocator<std::_Sp_counted_ptr_inplace<Mes, std::allocator<Mes>,
(__gnu_cxx::_Lock_policy)2> >&) <null> (a.out+0x88dc)
#4 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<Mes,
std::allocator<Mes>>(Mes*&, std::_Sp_alloc_shared_tag<std::allocator<Mes> >)
<null> (a.out+0x8215)
#5 std::__shared_ptr<Mes,
(__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<Mes>>(std::_Sp_alloc_shared_tag<std::allocator<Mes>
>) <null> (a.out+0x74b8)
#6
std::shared_ptr<Mes>::shared_ptr<std::allocator<Mes>>(std::_Sp_alloc_shared_tag<std::allocator<Mes>
>) <null> (a.out+0x6739)
#7 std::shared_ptr<Mes> std::allocate_shared<Mes,
std::allocator<Mes>>(std::allocator<Mes> const&) <null> (a.out+0x5646)
#8 std::shared_ptr<Mes> std::make_shared<Mes>() <null> (a.out+0x497c)
#9 Test::read() <null> (a.out+0x24bd)
#10 read_th() <null> (a.out+0x277a)
#11 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#12 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#13 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#14 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#15 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#16 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Location is heap block of size 24 at 0x7b0800001020 allocated by thread T1:
#0 operator new(unsigned long)
/build/gcc/src/gcc/libsanitizer/tsan/tsan_new_delete.cpp:64
(libtsan.so.0+0x91824)
#1 __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long,
void const*) <null> (a.out+0x9c51)
#2 std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >
>::allocate(std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) <null>
(a.out+0x943a)
#3 std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> > >
std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<Mes,
std::allocator<Mes>, (__gnu_cxx::_Lock_policy)2> >
>(std::allocator<std::_Sp_counted_ptr_inplace<Mes, std::allocator<Mes>,
(__gnu_cxx::_Lock_policy)2> >&) <null> (a.out+0x88dc)
#4 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<Mes,
std::allocator<Mes>>(Mes*&, std::_Sp_alloc_shared_tag<std::allocator<Mes> >)
<null> (a.out+0x8215)
#5 std::__shared_ptr<Mes,
(__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<Mes>>(std::_Sp_alloc_shared_tag<std::allocator<Mes>
>) <null> (a.out+0x74b8)
#6
std::shared_ptr<Mes>::shared_ptr<std::allocator<Mes>>(std::_Sp_alloc_shared_tag<std::allocator<Mes>
>) <null> (a.out+0x6739)
#7 std::shared_ptr<Mes> std::allocate_shared<Mes,
std::allocator<Mes>>(std::allocator<Mes> const&) <null> (a.out+0x5646)
#8 std::shared_ptr<Mes> std::make_shared<Mes>() <null> (a.out+0x497c)
#9 Test::read() <null> (a.out+0x24bd)
#10 read_th() <null> (a.out+0x277a)
#11 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#12 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#13 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#14 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#15 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#16 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Mutex M10 (0x562d5860c1c0) created at:
#0 pthread_mutex_lock
/build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4250
(libtsan.so.0+0x54b6a)
#1 __gthread_mutex_lock(pthread_mutex_t*) <null> (a.out+0x2df5)
#2 std::mutex::lock() <null> (a.out+0x2e7a)
#3 std::unique_lock<std::mutex>::lock() <null> (a.out+0x56f5)
#4 std::unique_lock<std::mutex>::unique_lock(std::mutex&) <null>
(a.out+0x4a32)
#5 Test::read() <null> (a.out+0x24d0)
#6 read_th() <null> (a.out+0x277a)
#7 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) <null> (a.out+0xa562)
#8 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0xa4b9)
#9 void std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (a.out+0xa41e)
#10 std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null>
(a.out+0xa3ae)
#11 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() <null> (a.out+0xa300)
#12 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)
Thread T2 (tid=76700, running) created by main thread at:
#0 pthread_create
/build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:969
(libtsan.so.0+0x61c3a)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
std::default_delete<std::thread::_State> >, void (*)())
/build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663
(libstdc++.so.6+0xd36aa)
#2 std::thread std::jthread::_S_create<void (&)()>(std::stop_source&, void
(&)()) <null> (a.out+0x5ef2)
#3 std::jthread::jthread<void (&)(), , void>(void (&)()) <null>
(a.out+0x4d9b)
#4 main <null> (a.out+0x2851)
Thread T1 (tid=76699, running) created by main thread at:
#0 pthread_create
/build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:969
(libtsan.so.0+0x61c3a)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
std::default_delete<std::thread::_State> >, void (*)())
/build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663
(libstdc++.so.6+0xd36aa)
#2 std::thread std::jthread::_S_create<void (&)()>(std::stop_source&, void
(&)()) <null> (a.out+0x5ef2)
#3 std::jthread::jthread<void (&)(), , void>(void (&)()) <null>
(a.out+0x4d9b)
#4 main <null> (a.out+0x283b)
SUMMARY: ThreadSanitizer: data race (/tmp/a.out+0x2692) in Test::check()
==================
More information about the Gcc-bugs
mailing list