Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: TSan reports data races for absl-based implementation of thread-safe queue, whereas for std:: based implementation the report is clear. #1771

Closed
lnikon opened this issue Oct 13, 2024 · 1 comment

Comments

@lnikon
Copy link

lnikon commented Oct 13, 2024

Describe the issue

Link to repo with reproducible examples: https://github.com/lnikon/abslstdthsqueues

This example contains implementations of two thread-safe queues. One relies on abseil synchronization primitives, and the other one on std::. Both implementations are conceptually the same, but TSan gives two warnings about data races on abseil implementation, and reports zero issues for std:: implementation.

Steps to reproduce the problem

First clone the example mentioned in description:\

git clone https://github.com/lnikon/abslstdthsqueues && cd abslstdthsqueues\

Then install absl via Conan2, generate project via CMake, and build. As a build result you will have two executables: AbslMain using abseil based thread-safe queue, and StdMain using std:: based one.\

conan install . --output-folder=build --build=missing --profile=default
cmake --preset conan-release
cmake --build ./build\

To run them:

./build/AbslMain
./build/StdMain

What version of Abseil are you using?

abseil/20240722.0

What operating system and version are you using?

Distro: Fedora Linux 40
Kernel: 6.10.12-200.fc40.x86_64

What compiler and version are you using?

clang version 18.1.8 (Fedora 18.1.8-1.fc40)

What build system are you using?

cmake version 3.28.2

Additional context

Output of tsan:

/usr/bin/llvm-symbolizer: error: '[stack]': No such file or directory
==================
WARNING: ThreadSanitizer: data race (pid=133798)
  Read of size 8 at 0x7ffe89654228 by thread T2:
    #0 std::operator==(std::_Deque_iterator<int, int&, int*> const&, std::_Deque_iterator<int, int&, int*> const&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/stl_deque.h:273:20 (AbslMain+0x4e7405) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #1 std::deque<int, std::allocator<int>>::empty() const /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/stl_deque.h:1348:40 (AbslMain+0x4e73b0) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #2 thread_safe_queue_t<int>::pop()::'lambda'(std::deque<int, std::allocator<int>>*)::operator()(std::deque<int, std::allocator<int>>*) const /home/nikon/src/personal/gh_issue_absl/absl_thread_safe_queue.h:23:54 (AbslMain+0x4e7361) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #3 thread_safe_queue_t<int>::pop()::'lambda'(std::deque<int, std::allocator<int>>*)::__invoke(std::deque<int, std::allocator<int>>*) /home/nikon/src/personal/gh_issue_absl/absl_thread_safe_queue.h:23:18 (AbslMain+0x4e7319) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #4 bool absl::lts_20240722::Condition::CastAndCallFunction<std::deque<int, std::allocator<int>>>(absl::lts_20240722::Condition const*) /home/nikon/.conan2/p/b/absei1968535e144c2/p/include/absl/synchronization/mutex.h:1100:10 (AbslMain+0x4e74ad) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #5 absl::lts_20240722::Condition::Eval() const /home/nikon/.conan2/p/b/absei1968535e144c2/b/src/absl/synchronization/mutex.cc:2783:53 (AbslMain+0x4f1330) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #6 thread_safe_queue_t<int>::pop() /home/nikon/src/personal/gh_issue_absl/absl_thread_safe_queue.h:21:18 (AbslMain+0x4e25c0) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #7 consumer(std::stop_token, thread_safe_queue_t<int>&) /home/nikon/src/personal/gh_issue_absl/absl_main.cpp:34:27 (AbslMain+0x4e2162) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #8 void std::__invoke_impl<void, void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>(std::__invoke_other, void (*&&)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token&&, std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/invoke.h:61:14 (AbslMain+0x4e8ed3) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #9 std::__invoke_result<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>::type std::__invoke<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>(void (*&&)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token&&, std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/invoke.h:96:14 (AbslMain+0x4e8d75) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #10 void std::thread::_Invoker<std::tuple<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>>::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/std_thread.h:301:13 (AbslMain+0x4e8d03) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #11 std::thread::_Invoker<std::tuple<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>>::operator()() /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/std_thread.h:308:11 (AbslMain+0x4e8c85) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #12 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>>>::_M_run() /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/std_thread.h:253:13 (AbslMain+0x4e86d9) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #13 <null> <null> (libstdc++.so.6+0xe7563) (BuildId: efdde18722aa72a0a779270371aeee5a9f6ddf87)

  Previous write of size 8 at 0x7ffe89654228 by thread T1:
    #0 int& std::deque<int, std::allocator<int>>::emplace_back<int>(int&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/deque.tcc:173:6 (AbslMain+0x4e5b49) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #1 thread_safe_queue_t<int>::push(int) /home/nikon/src/personal/gh_issue_absl/absl_thread_safe_queue.h:16:13 (AbslMain+0x4e2485) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #2 producer(std::stop_token, thread_safe_queue_t<int>&) /home/nikon/src/personal/gh_issue_absl/absl_main.cpp:16:15 (AbslMain+0x4e20cd) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #3 void std::__invoke_impl<void, void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>(std::__invoke_other, void (*&&)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token&&, std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/invoke.h:61:14 (AbslMain+0x4e8ed3) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #4 std::__invoke_result<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>::type std::__invoke<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>(void (*&&)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token&&, std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/invoke.h:96:14 (AbslMain+0x4e8d75) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #5 void std::thread::_Invoker<std::tuple<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>>::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/std_thread.h:301:13 (AbslMain+0x4e8d03) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #6 std::thread::_Invoker<std::tuple<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>>::operator()() /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/std_thread.h:308:11 (AbslMain+0x4e8c85) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #7 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>>>::_M_run() /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/std_thread.h:253:13 (AbslMain+0x4e86d9) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #8 <null> <null> (libstdc++.so.6+0xe7563) (BuildId: efdde18722aa72a0a779270371aeee5a9f6ddf87)

  Location is stack of main thread.

  Location is global '??' at 0x7ffe89634000 ([stack]+0x20228)

  Thread T2 (tid=133801, running) created by main thread at:
    #0 pthread_create <null> (AbslMain+0x461bcf) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) <null> (libstdc++.so.6+0xe7638) (BuildId: efdde18722aa72a0a779270371aeee5a9f6ddf87)
    #2 std::thread std::jthread::_S_create<void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>>(std::stop_source&, void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/thread:266:11 (AbslMain+0x4e7de5) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #3 std::jthread::jthread<void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>, void>(void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/thread:163:19 (AbslMain+0x4e28a5) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #4 main /home/nikon/src/personal/gh_issue_absl/absl_main.cpp:44:27 (AbslMain+0x4e2264) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)

  Thread T1 (tid=133800, finished) created by main thread at:
    #0 pthread_create <null> (AbslMain+0x461bcf) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) <null> (libstdc++.so.6+0xe7638) (BuildId: efdde18722aa72a0a779270371aeee5a9f6ddf87)
    #2 std::thread std::jthread::_S_create<void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>>(std::stop_source&, void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/thread:266:11 (AbslMain+0x4e7de5) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #3 std::jthread::jthread<void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>, void>(void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/thread:163:19 (AbslMain+0x4e28a5) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #4 main /home/nikon/src/personal/gh_issue_absl/absl_main.cpp:43:27 (AbslMain+0x4e2237) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)

SUMMARY: ThreadSanitizer: data race /home/nikon/src/personal/gh_issue_absl/absl_thread_safe_queue.h:23:54 in thread_safe_queue_t<int>::pop()::'lambda'(std::deque<int, std::allocator<int>>*)::operator()(std::deque<int, std::allocator<int>>*) const
==================
==================
WARNING: ThreadSanitizer: data race (pid=133798)
  Read of size 4 at 0x725000000000 by thread T2:
    #0 std::_Optional_payload_base<int>::_Storage<int, true>::_Storage<int&>(std::in_place_t, int&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/optional:210:17 (AbslMain+0x4e7bdd) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #1 std::_Optional_payload_base<int>::_Optional_payload_base<int&>(std::in_place_t, int&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/optional:122:4 (AbslMain+0x4e7b79) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #2 std::_Optional_payload<int, true, true, true>::_Optional_payload<int&>(std::in_place_t, int&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/optional:337:42 (AbslMain+0x4e7b15) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #3 std::_Optional_base<int, true, true>::_Optional_base<int&, false>(std::in_place_t, int&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/optional:648:4 (AbslMain+0x4e7ab5) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #4 std::optional<int>::optional<int&, true>(int&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/optional:747:4 (AbslMain+0x4e7a65) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #5 std::enable_if<is_constructible_v<std::decay<int&>::type, int&>, std::optional<std::decay<int&>::type>>::type std::make_optional<int&>(int&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/optional:1460:14 (AbslMain+0x4e7179) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #6 thread_safe_queue_t<int>::pop() /home/nikon/src/personal/gh_issue_absl/absl_thread_safe_queue.h:28:17 (AbslMain+0x4e2627) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #7 consumer(std::stop_token, thread_safe_queue_t<int>&) /home/nikon/src/personal/gh_issue_absl/absl_main.cpp:34:27 (AbslMain+0x4e2162) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #8 void std::__invoke_impl<void, void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>(std::__invoke_other, void (*&&)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token&&, std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/invoke.h:61:14 (AbslMain+0x4e8ed3) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #9 std::__invoke_result<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>::type std::__invoke<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>(void (*&&)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token&&, std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/invoke.h:96:14 (AbslMain+0x4e8d75) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #10 void std::thread::_Invoker<std::tuple<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>>::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/std_thread.h:301:13 (AbslMain+0x4e8d03) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #11 std::thread::_Invoker<std::tuple<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>>::operator()() /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/std_thread.h:308:11 (AbslMain+0x4e8c85) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #12 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>>>::_M_run() /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/std_thread.h:253:13 (AbslMain+0x4e86d9) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #13 <null> <null> (libstdc++.so.6+0xe7563) (BuildId: efdde18722aa72a0a779270371aeee5a9f6ddf87)

  Previous write of size 4 at 0x725000000000 by thread T1:
    #0 decltype(::new((void*)(0)) int(std::declval<int>())) std::construct_at<int, int>(int*, int&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/stl_construct.h:97:14 (AbslMain+0x4e5e4f) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #1 void std::allocator_traits<std::allocator<int>>::construct<int, int>(std::allocator<int>&, int*, int&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/alloc_traits.h:536:4 (AbslMain+0x4e5b2d) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #2 int& std::deque<int, std::allocator<int>>::emplace_back<int>(int&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/deque.tcc:170:6 (AbslMain+0x4e5b2d)
    #3 thread_safe_queue_t<int>::push(int) /home/nikon/src/personal/gh_issue_absl/absl_thread_safe_queue.h:16:13 (AbslMain+0x4e2485) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #4 producer(std::stop_token, thread_safe_queue_t<int>&) /home/nikon/src/personal/gh_issue_absl/absl_main.cpp:16:15 (AbslMain+0x4e20cd) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #5 void std::__invoke_impl<void, void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>(std::__invoke_other, void (*&&)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token&&, std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/invoke.h:61:14 (AbslMain+0x4e8ed3) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #6 std::__invoke_result<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>::type std::__invoke<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>(void (*&&)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token&&, std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/invoke.h:96:14 (AbslMain+0x4e8d75) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #7 void std::thread::_Invoker<std::tuple<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>>::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/std_thread.h:301:13 (AbslMain+0x4e8d03) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #8 std::thread::_Invoker<std::tuple<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>>::operator()() /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/std_thread.h:308:11 (AbslMain+0x4e8c85) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #9 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(std::stop_token, thread_safe_queue_t<int>&), std::stop_token, std::reference_wrapper<thread_safe_queue_t<int>>>>>::_M_run() /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/std_thread.h:253:13 (AbslMain+0x4e86d9) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #10 <null> <null> (libstdc++.so.6+0xe7563) (BuildId: efdde18722aa72a0a779270371aeee5a9f6ddf87)

  Location is heap block of size 512 at 0x725000000000 allocated by main thread:
    #0 operator new(unsigned long) <null> (AbslMain+0x4e114b) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #1 std::__new_allocator<int>::allocate(unsigned long, void const*) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/new_allocator.h:151:27 (AbslMain+0x4e3c18) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #2 std::allocator<int>::allocate(unsigned long) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/allocator.h:196:32 (AbslMain+0x4e3acb) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #3 std::allocator_traits<std::allocator<int>>::allocate(std::allocator<int>&, unsigned long) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/alloc_traits.h:478:20 (AbslMain+0x4e3acb)
    #4 std::_Deque_base<int, std::allocator<int>>::_M_allocate_node() /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/stl_deque.h:583:9 (AbslMain+0x4e3acb)
    #5 std::_Deque_base<int, std::allocator<int>>::_M_create_nodes(int**, int**) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/stl_deque.h:684:21 (AbslMain+0x4e36eb) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #6 std::_Deque_base<int, std::allocator<int>>::_M_initialize_map(unsigned long) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/stl_deque.h:658:4 (AbslMain+0x4e3235) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #7 std::_Deque_base<int, std::allocator<int>>::_Deque_base() /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/stl_deque.h:460:9 (AbslMain+0x4e3036) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #8 std::deque<int, std::allocator<int>>::deque() /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/stl_deque.h:855:7 (AbslMain+0x4e2f25) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #9 thread_safe_queue_t<int>::thread_safe_queue_t() /home/nikon/src/personal/gh_issue_absl/absl_thread_safe_queue.h:10:33 (AbslMain+0x4e2772) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #10 main /home/nikon/src/personal/gh_issue_absl/absl_main.cpp:41:30 (AbslMain+0x4e2213) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)

  Thread T2 (tid=133801, running) created by main thread at:
    #0 pthread_create <null> (AbslMain+0x461bcf) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) <null> (libstdc++.so.6+0xe7638) (BuildId: efdde18722aa72a0a779270371aeee5a9f6ddf87)
    #2 std::thread std::jthread::_S_create<void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>>(std::stop_source&, void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/thread:266:11 (AbslMain+0x4e7de5) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #3 std::jthread::jthread<void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>, void>(void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/thread:163:19 (AbslMain+0x4e28a5) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #4 main /home/nikon/src/personal/gh_issue_absl/absl_main.cpp:44:27 (AbslMain+0x4e2264) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)

  Thread T1 (tid=133800, finished) created by main thread at:
    #0 pthread_create <null> (AbslMain+0x461bcf) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) <null> (libstdc++.so.6+0xe7638) (BuildId: efdde18722aa72a0a779270371aeee5a9f6ddf87)
    #2 std::thread std::jthread::_S_create<void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>>(std::stop_source&, void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/thread:266:11 (AbslMain+0x4e7de5) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #3 std::jthread::jthread<void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>, void>(void (&)(std::stop_token, thread_safe_queue_t<int>&), std::reference_wrapper<thread_safe_queue_t<int>>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/thread:163:19 (AbslMain+0x4e28a5) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)
    #4 main /home/nikon/src/personal/gh_issue_absl/absl_main.cpp:43:27 (AbslMain+0x4e2237) (BuildId: 7a1c4eb920d3ac287c60a6e3e7168ebeb5f0c62b)

SUMMARY: ThreadSanitizer: data race /home/nikon/src/personal/gh_issue_absl/absl_thread_safe_queue.h:28:17 in thread_safe_queue_t<int>::pop()
==================
Consumed: 0
ThreadSanitizer: reported 2 warnings
@derekmauro
Copy link
Member

derekmauro commented Oct 14, 2024

You need a copy of the Abseil library built with ThreadSanitizer. If you are just getting pre-compiled code from Conan, that will not be the case.

https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual#non-instrumented-code

@derekmauro derekmauro closed this as not planned Won't fix, can't repro, duplicate, stale Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants