Skip to content

Instantly share code, notes, and snippets.

@drodil
Created September 28, 2018 18:17
Show Gist options
  • Save drodil/a6d5f65ddf26d5d57deebc7c24b0468c to your computer and use it in GitHub Desktop.
Save drodil/a6d5f65ddf26d5d57deebc7c24b0468c to your computer and use it in GitHub Desktop.
T0 increasing counter
T1 increasing counter
==================
WARNING: ThreadSanitizer: data race (pid=4888)
Write of size 8 at 0x0000011b4980 by thread T2:
#0 foo() ??:? (a.out+0x4c521b)
#1 void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) ??:? (a.out+0x4cbeb5)
#2 std::_Bind_simple<void (*())()>::operator()() ??:? (a.out+0x4cbe48)
#3 std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() ??:? (a.out+0x4cbaac)
#4 std::this_thread::__sleep_for(std::chrono::duration<long, std::ratio<1l, 1l> >, std::chrono::duration<long, std::ratio<1l, 1000000000l> >) ??:? (libstdc++.so.6+0xb8c7f)
Previous write of size 8 at 0x0000011b4980 by thread T1:
#0 foo() ??:? (a.out+0x4c521b)
#1 void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) ??:? (a.out+0x4cbeb5)
#2 std::_Bind_simple<void (*())()>::operator()() ??:? (a.out+0x4cbe48)
#3 std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() ??:? (a.out+0x4cbaac)
#4 std::this_thread::__sleep_for(std::chrono::duration<long, std::ratio<1l, 1l> >, std::chrono::duration<long, std::ratio<1l, 1000000000l> >) ??:? (libstdc++.so.6+0xb8c7f)
Location is global '<null>' at 0x000000000000 (a.out+0x0000011b4980)
Thread T2 (tid=4891, running) created by main thread at:
#0 pthread_create ??:? (a.out+0x42924b)
#1 std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>, void (*)()) ??:? (libstdc++.so.6+0xb8dc2)
#2 void __gnu_cxx::new_allocator<std::thread>::construct<std::thread, void (&)()>(std::thread*, void (&)()) ??:? (a.out+0x4ca3d7)
#3 void std::allocator_traits<std::allocator<std::thread> >::construct<std::thread, void (&)()>(std::allocator<std::thread>&, std::thread*, void (&)()) ??:? (a.out+0x4c9f83)
#4 void std::vector<std::thread, std::allocator<std::thread> >::_M_emplace_back_aux<void (&)()>(void (&)()) ??:? (a.out+0x4ca072)
#5 void std::vector<std::thread, std::allocator<std::thread> >::emplace_back<void (&)()>(void (&)()) ??:? (a.out+0x4c5cac)
#6 main ??:? (a.out+0x4c52cf)
Thread T1 (tid=4890, finished) created by main thread at:
#0 pthread_create ??:? (a.out+0x42924b)
#1 std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>, void (*)()) ??:? (libstdc++.so.6+0xb8dc2)
#2 void __gnu_cxx::new_allocator<std::thread>::construct<std::thread, void (&)()>(std::thread*, void (&)()) ??:? (a.out+0x4ca3d7)
#3 void std::allocator_traits<std::allocator<std::thread> >::construct<std::thread, void (&)()>(std::allocator<std::thread>&, std::thread*, void (&)()) ??:? (a.out+0x4c9f83)
#4 void std::vector<std::thread, std::allocator<std::thread> >::_M_emplace_back_aux<void (&)()>(void (&)()) ??:? (a.out+0x4ca072)
#5 void std::vector<std::thread, std::allocator<std::thread> >::emplace_back<void (&)()>(void (&)()) ??:? (a.out+0x4c5cac)
#6 main ??:? (a.out+0x4c52cf)
SUMMARY: ThreadSanitizer: data race ??:? in foo()
==================
ThreadSanitizer: reported 1 warnings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment