Comments (3)
How are you running the Catch2 binary? Because on its own, that should not be a race, as the default reporter in an otherwise "empty" binary should not touch std::cout
.
from catch2.
UPDATE: The log is similar to the output of ./bazel-out/k8-dbg/bin/test -r xml
. However, when I add a custom main to print argc and argv, argc is 1.
UPDATE: It fails when running bazelisk test //:test --config tsan -c dbg
and successes when running ./bazel-out/k8-dbg/bin/test
. So, compilation should be OK.
Thanks for your reply. I cannot reproduce using CMake. Only occurs when using Bazel? I'll investigate tomorrow. And TSan log is listed as follows.
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //:test
-----------------------------------------------------------------------------
Warning: Bazel shard configuration is missing 'TEST_SHARD_INDEX'. Shard configuration is skipped.
Warning: Bazel shard configuration is missing 'TEST_TOTAL_SHARDS'. Shard configuration is skipped.
Warning: Bazel shard configuration is missing 'TEST_SHARD_STATUS_FILE'. Shard configuration is skipped.
==================
WARNING: ThreadSanitizer: data race (pid=12)
Read of size 8 at 0x7b48000004e0 by thread T2:
#0 __tsan_memcpy /usr/src/debug/gcc/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:3081 (libtsan.so.2+0x79499) (BuildId: c39405aada755398a542cde01e23149afb1204d1)
#1 std::char_traits<char>::copy(char*, char const*, unsigned long) /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:445 (libstdc++.so.6+0x14d62f) (BuildId: 26d15cc010d7e7c8831795d6b4f135e1d1958ee1)
#2 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy(char*, char const*, unsigned long) /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:420 (libstdc++.so.6+0x14d62f)
#3 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy(char*, char const*, unsigned long) /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:415 (libstdc++.so.6+0x14d62f)
#4 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long) /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:537 (libstdc++.so.6+0x14d62f)
#5 __invoke_impl<void, CATCH2_INTERNAL_TEST_0()::<lambda()> > /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/invoke.h:61 (test+0x7a28b) (BuildId: 577e7e401b3a6ba0)
#6 __invoke<CATCH2_INTERNAL_TEST_0()::<lambda()> > /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/invoke.h:96 (test+0x7a16b) (BuildId: 577e7e401b3a6ba0)
#7 _M_invoke<0> /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/std_thread.h:292 (test+0x7a07a) (BuildId: 577e7e401b3a6ba0)
#8 operator() /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/std_thread.h:299 (test+0x79fde) (BuildId: 577e7e401b3a6ba0)
#9 _M_run /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/std_thread.h:244 (test+0x79f4e) (BuildId: 577e7e401b3a6ba0)
#10 execute_native_thread_routine /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:104 (libstdc++.so.6+0xe1942) (BuildId: 26d15cc010d7e7c8831795d6b4f135e1d1958ee1)
Previous write of size 7 at 0x7b48000004e1 by thread T1:
#0 __tsan_memcpy /usr/src/debug/gcc/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:3081 (libtsan.so.2+0x79499) (BuildId: c39405aada755398a542cde01e23149afb1204d1)
#1 std::char_traits<char>::copy(char*, char const*, unsigned long) /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:445 (libstdc++.so.6+0x157ece) (BuildId: 26d15cc010d7e7c8831795d6b4f135e1d1958ee1)
#2 std::basic_streambuf<char, std::char_traits<char> >::xsputn(char const*, long) /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/streambuf.tcc:90 (libstdc++.so.6+0x157ece)
#3 __invoke_impl<void, CATCH2_INTERNAL_TEST_0()::<lambda()> > /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/invoke.h:61 (test+0x7a310) (BuildId: 577e7e401b3a6ba0)
#4 __invoke<CATCH2_INTERNAL_TEST_0()::<lambda()> > /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/invoke.h:96 (test+0x7a206) (BuildId: 577e7e401b3a6ba0)
#5 _M_invoke<0> /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/std_thread.h:292 (test+0x7a0d0) (BuildId: 577e7e401b3a6ba0)
#6 operator() /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/std_thread.h:299 (test+0x7a024) (BuildId: 577e7e401b3a6ba0)
#7 _M_run /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/std_thread.h:244 (test+0x79f98) (BuildId: 577e7e401b3a6ba0)
#8 execute_native_thread_routine /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:104 (libstdc++.so.6+0xe1942) (BuildId: 26d15cc010d7e7c8831795d6b4f135e1d1958ee1)
Location is heap block of size 376 at 0x7b4800000480 allocated by main thread:
#0 operator new(unsigned long) /usr/src/debug/gcc/gcc/libsanitizer/tsan/tsan_new_delete.cpp:64 (libtsan.so.2+0x932ff) (BuildId: c39405aada755398a542cde01e23149afb1204d1)
#1 Catch::Detail::unique_ptr<std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> > > Catch::Detail::make_unique<std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >>() external/com_github_catchorg_catch2/src/catch2/internal/catch_unique_ptr.hpp:111 (test+0xfcd9c) (BuildId: 577e7e401b3a6ba0)
#2 Catch::StringStreams::add() external/com_github_catchorg_catch2/src/catch2/internal/catch_reusable_string_stream.cpp:26 (test+0xfcbca) (BuildId: 577e7e401b3a6ba0)
#3 Catch::ReusableStringStream::ReusableStringStream() external/com_github_catchorg_catch2/src/catch2/internal/catch_reusable_string_stream.cpp:43 (test+0xfc903) (BuildId: 577e7e401b3a6ba0)
#4 Catch::RedirectedStdOut::RedirectedStdOut() external/com_github_catchorg_catch2/src/catch2/internal/catch_output_redirect.cpp:42 (test+0x10e942) (BuildId: 577e7e401b3a6ba0)
#5 Catch::RedirectedStreams::RedirectedStreams(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) external/com_github_catchorg_catch2/src/catch2/internal/catch_output_redirect.cpp:53 (test+0x10eb75) (BuildId: 577e7e401b3a6ba0)
#6 Catch::RunContext::runCurrentTest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) external/com_github_catchorg_catch2/src/catch2/internal/catch_run_context.cpp:506 (test+0x10389b) (BuildId: 577e7e401b3a6ba0)
#7 Catch::RunContext::runTest(Catch::TestCaseHandle const&) external/com_github_catchorg_catch2/src/catch2/internal/catch_run_context.cpp:239 (test+0x1013f0) (BuildId: 577e7e401b3a6ba0)
#8 execute external/com_github_catchorg_catch2/src/catch2/catch_session.cpp:111 (test+0x7bb71) (BuildId: 577e7e401b3a6ba0)
#9 Catch::Session::runInternal() external/com_github_catchorg_catch2/src/catch2/catch_session.cpp:333 (test+0x7d461) (BuildId: 577e7e401b3a6ba0)
#10 Catch::Session::run() external/com_github_catchorg_catch2/src/catch2/catch_session.cpp:264 (test+0x7ce32) (BuildId: 577e7e401b3a6ba0)
#11 int Catch::Session::run<char>(int, char const* const*) external/com_github_catchorg_catch2/src/catch2/catch_session.hpp:41 (test+0x7ad65) (BuildId: 577e7e401b3a6ba0)
#12 main external/com_github_catchorg_catch2/src/catch2/internal/catch_main.cpp:36 (test+0x7abf4) (BuildId: 577e7e401b3a6ba0)
Thread T2 (tid=19, running) created by main thread at:
#0 pthread_create /usr/src/debug/gcc/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:1036 (libtsan.so.2+0x44219) (BuildId: c39405aada755398a542cde01e23149afb1204d1)
#1 __gthread_create /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663 (libstdc++.so.6+0xe1a29) (BuildId: 26d15cc010d7e7c8831795d6b4f135e1d1958ee1)
#2 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:172 (libstdc++.so.6+0xe1a29)
#3 CATCH2_INTERNAL_TEST_0 src/test.cpp:12 (test+0x79788) (BuildId: 577e7e401b3a6ba0)
#4 invoke external/com_github_catchorg_catch2/src/catch2/internal/catch_test_registry.cpp:58 (test+0x12d628) (BuildId: 577e7e401b3a6ba0)
#5 Catch::TestCaseHandle::invoke() const external/com_github_catchorg_catch2/src/catch2/catch_test_case_info.hpp:116 (test+0x1055c8) (BuildId: 577e7e401b3a6ba0)
#6 Catch::RunContext::invokeActiveTestCase() external/com_github_catchorg_catch2/src/catch2/internal/catch_run_context.cpp:554 (test+0x103c8a) (BuildId: 577e7e401b3a6ba0)
#7 Catch::RunContext::runCurrentTest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) external/com_github_catchorg_catch2/src/catch2/internal/catch_run_context.cpp:509 (test+0x1038b9) (BuildId: 577e7e401b3a6ba0)
#8 Catch::RunContext::runTest(Catch::TestCaseHandle const&) external/com_github_catchorg_catch2/src/catch2/internal/catch_run_context.cpp:239 (test+0x1013f0) (BuildId: 577e7e401b3a6ba0)
#9 execute external/com_github_catchorg_catch2/src/catch2/catch_session.cpp:111 (test+0x7bb71) (BuildId: 577e7e401b3a6ba0)
#10 Catch::Session::runInternal() external/com_github_catchorg_catch2/src/catch2/catch_session.cpp:333 (test+0x7d461) (BuildId: 577e7e401b3a6ba0)
#11 Catch::Session::run() external/com_github_catchorg_catch2/src/catch2/catch_session.cpp:264 (test+0x7ce32) (BuildId: 577e7e401b3a6ba0)
#12 int Catch::Session::run<char>(int, char const* const*) external/com_github_catchorg_catch2/src/catch2/catch_session.hpp:41 (test+0x7ad65) (BuildId: 577e7e401b3a6ba0)
#13 main external/com_github_catchorg_catch2/src/catch2/internal/catch_main.cpp:36 (test+0x7abf4) (BuildId: 577e7e401b3a6ba0)
Thread T1 (tid=18, finished) created by main thread at:
#0 pthread_create /usr/src/debug/gcc/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:1036 (libtsan.so.2+0x44219) (BuildId: c39405aada755398a542cde01e23149afb1204d1)
#1 __gthread_create /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663 (libstdc++.so.6+0xe1a29) (BuildId: 26d15cc010d7e7c8831795d6b4f135e1d1958ee1)
#2 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:172 (libstdc++.so.6+0xe1a29)
#3 CATCH2_INTERNAL_TEST_0 src/test.cpp:9 (test+0x79775) (BuildId: 577e7e401b3a6ba0)
#4 invoke external/com_github_catchorg_catch2/src/catch2/internal/catch_test_registry.cpp:58 (test+0x12d628) (BuildId: 577e7e401b3a6ba0)
#5 Catch::TestCaseHandle::invoke() const external/com_github_catchorg_catch2/src/catch2/catch_test_case_info.hpp:116 (test+0x1055c8) (BuildId: 577e7e401b3a6ba0)
#6 Catch::RunContext::invokeActiveTestCase() external/com_github_catchorg_catch2/src/catch2/internal/catch_run_context.cpp:554 (test+0x103c8a) (BuildId: 577e7e401b3a6ba0)
#7 Catch::RunContext::runCurrentTest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) external/com_github_catchorg_catch2/src/catch2/internal/catch_run_context.cpp:509 (test+0x1038b9) (BuildId: 577e7e401b3a6ba0)
#8 Catch::RunContext::runTest(Catch::TestCaseHandle const&) external/com_github_catchorg_catch2/src/catch2/internal/catch_run_context.cpp:239 (test+0x1013f0) (BuildId: 577e7e401b3a6ba0)
#9 execute external/com_github_catchorg_catch2/src/catch2/catch_session.cpp:111 (test+0x7bb71) (BuildId: 577e7e401b3a6ba0)
#10 Catch::Session::runInternal() external/com_github_catchorg_catch2/src/catch2/catch_session.cpp:333 (test+0x7d461) (BuildId: 577e7e401b3a6ba0)
#11 Catch::Session::run() external/com_github_catchorg_catch2/src/catch2/catch_session.cpp:264 (test+0x7ce32) (BuildId: 577e7e401b3a6ba0)
#12 int Catch::Session::run<char>(int, char const* const*) external/com_github_catchorg_catch2/src/catch2/catch_session.hpp:41 (test+0x7ad65) (BuildId: 577e7e401b3a6ba0)
#13 main external/com_github_catchorg_catch2/src/catch2/internal/catch_main.cpp:36 (test+0x7abf4) (BuildId: 577e7e401b3a6ba0)
SUMMARY: ThreadSanitizer: data race /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:445 in std::char_traits<char>::copy(char*, char const*, unsigned long)
==================
Randomness seeded to: 2909095295
0123456789 ===============================================================================
test cases: 1 | 1 passed
assertions: - none -
ThreadSanitizer: reported 1 warnings
from catch2.
I think this result is expected. According to https://bazel.build/reference/test-encyclopedia, Bazel sets XML_OUTPUT_FILE
optionally. Catch2 honors this Env and adds an XML reporter which results in data-race.
XML_OUTPUT_FILE=1 BAZEL_TEST=1 ./bazel-out/k8-dbg/bin/test
This can reproduce data race.
from catch2.
Related Issues (20)
- Generator results into a fatal error in 2.13.9 (newest not tested)
- Supplying own command line options by following the documentation results in UB (?) HOT 1
- `--benchmark-samples` does not seem to work as expected HOT 4
- I place a benchmark inside a TEST_CASE() and I don't see the results HOT 2
- Wunused-variable in (DYNAMIC_)SECTION when CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT is enabled HOT 1
- XML Reporter doesn't output stderr / stdin when there is a segfault HOT 3
- unnecessary double promotion generate warning.
- Support multiple reporters for `catch_discover_tests` HOT 1
- Integrate Generators into reporters and CLI HOT 2
- Extend support for randomness generation in tests
- Finish JSON reporter & use it for more reliable CMake/CTest integration
- Update documentation for v3 HOT 2
- Provide Catch2's StringMaker specialization behind extra level of indirection
- Handle ANSI escape sequences during text wrapping
- Bring back Single-Header capability HOT 2
- AddressSanitizer reports container overflow during benchmarking HOT 3
- Latest macOS system header causes compilation failures on GCC HOT 4
- Compilation fails with `error: arithmetic on a pointer to an incomplete type` HOT 1
- Combine test filters with filenames HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from catch2.