We spot a data race internally and fix it, here a way to reproduce it (patch incoming !)
on this 100 runs, get 3 times a bazel trace logs...
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //:TestHighsParallel
-----------------------------------------------------------------------------
==================
WARNING: ThreadSanitizer: data race (pid=12)
Write of size 8 at 0x72600001bc00 by main thread:
#0 free <null> (TestHighsParallel+0xa2e36) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#1 deallocate_matrix() /proc/self/cwd/check/matrix_multiplication.hpp:32:5 (TestHighsParallel+0x1296dd) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#2 matrix_multiplication(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned int, unsigned int) /proc/self/cwd/check/TestHighsParallel.cpp:218:5 (TestHighsParallel+0x1296dd)
#3 C_A_T_C_H_T_E_S_T_0() /proc/self/cwd/check/TestHighsParallel.cpp:226:3 (TestHighsParallel+0x12988f) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#4 Catch::TestInvokerAsFunction::invoke() const /proc/self/cwd/extern/catch.hpp:15015:46 (liblibtest_Ulib.so+0xae0fd) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#5 Catch::TestCase::invoke() const /proc/self/cwd/extern/catch.hpp:14853:39 (liblibtest_Ulib.so+0xa1af0) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#6 Catch::RunContext::invokeActiveTestCase() /proc/self/cwd/extern/catch.hpp:13741:21 (liblibtest_Ulib.so+0xa1af0)
#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>>&) /proc/self/cwd/extern/catch.hpp:13710:7 (liblibtest_Ulib.so+0x9eb5b) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#8 Catch::RunContext::runTest(Catch::TestCase const&) /proc/self/cwd/extern/catch.hpp:13477:5 (liblibtest_Ulib.so+0x9d7d6) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#9 Catch::(anonymous namespace)::TestGroup::execute() /proc/self/cwd/extern/catch.hpp:14040:29 (liblibtest_Ulib.so+0xa6f88) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#10 Catch::Session::runInternal() /proc/self/cwd/extern/catch.hpp:14238:31 (liblibtest_Ulib.so+0xa6f88)
#11 Catch::Session::run() /proc/self/cwd/extern/catch.hpp:14202:18 (liblibtest_Ulib.so+0xa5891) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#12 int Catch::Session::run<char>(int, char const* const*) /proc/self/cwd/extern/catch.hpp:13924:39 (liblibtest_Ulib.so+0xccd46) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#13 main /proc/self/cwd/extern/catch.hpp:18157:27 (liblibtest_Ulib.so+0xccd46)
Previous read of size 8 at 0x72600001bc00 by thread T12:
#0 matrix_multiplication_highs(unsigned int)::$_3::operator()(int, int) const /proc/self/cwd/check/TestHighsParallel.cpp:164:22 (TestHighsParallel+0x12baf7) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#1 void highs::parallel::for_each<matrix_multiplication_highs(unsigned int)::$_3&>(int, int, matrix_multiplication_highs(unsigned int)::$_3&, int) /proc/self/cwd/highs/parallel/HighsParallel.h:119:5 (TestHighsParallel+0x12baf7)
#2 void highs::parallel::for_each<matrix_multiplication_highs(unsigned int)::$_3&>(int, int, matrix_multiplication_highs(unsigned int)::$_3&, int)::'lambda'()::operator()() const /proc/self/cwd/highs/parallel/HighsParallel.h:114:9 (TestHighsParallel+0x12bd18) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#3 HighsTask::Callable<void highs::parallel::for_each<matrix_multiplication_highs(unsigned int)::$_3&>(int, int, matrix_multiplication_highs(unsigned int)::$_3&, int)::'lambda'()>::operator()() /proc/self/cwd/highs/parallel/HighsTask.h:52:7 (TestHighsParallel+0x12bd18)
#4 HighsTask::run(HighsSplitDeque*) /proc/self/cwd/highs/parallel/HighsTask.h:84:21 (TestHighsParallel+0x12ccc3) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#5 HighsSplitDeque::runStolenTask(HighsTask*) /proc/self/cwd/highs/parallel/HighsSplitDeque.h:478:38 (TestHighsParallel+0x12ccc3)
#6 HighsTaskExecutor::run_worker(int, HighsTaskExecutor*) /proc/self/cwd/highs/parallel/HighsTaskExecutor.h:98:21 (TestHighsParallel+0x12e73e) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#7 void std::__invoke_impl<void, void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>(std::__invoke_other, void (*&&)(int, HighsTaskExecutor*), int&&, HighsTaskExecutor*&&) /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/invoke.h:63:14 (TestHighsParallel+0x12f8a9) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#8 std::__invoke_result<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>::type std::__invoke<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>(void (*&&)(int, HighsTaskExecutor*), int&&, HighsTaskExecutor*&&) /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/invoke.h:98:14 (TestHighsParallel+0x12f8a9)
#9 void std::thread::_Invoker<std::tuple<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>>::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/std_thread.h:303:13 (TestHighsParallel+0x12f8a9)
#10 std::thread::_Invoker<std::tuple<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>>::operator()() /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/std_thread.h:310:11 (TestHighsParallel+0x12f8a9)
#11 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>>>::_M_run() /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/std_thread.h:255:13 (TestHighsParallel+0x12f8a9)
#12 <null> <null> (libstdc++.so.6+0xe6d63) (BuildId: 96c2652d0588b7979060cdc3d0bdb0fbcfdecc9a)
Thread T12 (tid=30, running) created by main thread at:
#0 pthread_create <null> (TestHighsParallel+0xa4295) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) <null> (libstdc++.so.6+0xe6e38) (BuildId: 96c2652d0588b7979060cdc3d0bdb0fbcfdecc9a)
#2 HighsTaskExecutor::HighsTaskExecutor(int) /proc/self/cwd/highs/parallel/HighsTaskExecutor.h:126:21 (TestHighsParallel+0x12e1d3) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#3 HighsTaskExecutor::initialize(int) /proc/self/cwd/highs/parallel/HighsTaskExecutor.h:165:11 (TestHighsParallel+0x129844) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#4 highs::parallel::initialize_scheduler(int) /proc/self/cwd/highs/parallel/HighsParallel.h:28:3 (TestHighsParallel+0x129844)
#5 C_A_T_C_H_T_E_S_T_0() /proc/self/cwd/check/TestHighsParallel.cpp:224:3 (TestHighsParallel+0x129844)
#6 Catch::TestInvokerAsFunction::invoke() const /proc/self/cwd/extern/catch.hpp:15015:46 (liblibtest_Ulib.so+0xae0fd) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#7 Catch::TestCase::invoke() const /proc/self/cwd/extern/catch.hpp:14853:39 (liblibtest_Ulib.so+0xa1af0) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#8 Catch::RunContext::invokeActiveTestCase() /proc/self/cwd/extern/catch.hpp:13741:21 (liblibtest_Ulib.so+0xa1af0)
#9 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>>&) /proc/self/cwd/extern/catch.hpp:13710:7 (liblibtest_Ulib.so+0x9eb5b) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#10 Catch::RunContext::runTest(Catch::TestCase const&) /proc/self/cwd/extern/catch.hpp:13477:5 (liblibtest_Ulib.so+0x9d7d6) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#11 Catch::(anonymous namespace)::TestGroup::execute() /proc/self/cwd/extern/catch.hpp:14040:29 (liblibtest_Ulib.so+0xa6f88) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#12 Catch::Session::runInternal() /proc/self/cwd/extern/catch.hpp:14238:31 (liblibtest_Ulib.so+0xa6f88)
#13 Catch::Session::run() /proc/self/cwd/extern/catch.hpp:14202:18 (liblibtest_Ulib.so+0xa5891) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#14 int Catch::Session::run<char>(int, char const* const*) /proc/self/cwd/extern/catch.hpp:13924:39 (liblibtest_Ulib.so+0xccd46) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#15 main /proc/self/cwd/extern/catch.hpp:18157:27 (liblibtest_Ulib.so+0xccd46)
SUMMARY: ThreadSanitizer: data race (/usr/local/google/home/corentinl/.cache/bazel/_bazel_corentinl/4a2721af6f58579727dc4fe79c840cbc/execroot/_main/bazel-out/k8-fastbuild/bin/TestHighsParallel+0xa2e36) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d) in free
==================
==================
WARNING: ThreadSanitizer: data race (pid=12)
Write of size 8 at 0x72600001c400 by main thread:
#0 free <null> (TestHighsParallel+0xa2e36) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#1 deallocate_matrix() /proc/self/cwd/check/matrix_multiplication.hpp:34:5 (TestHighsParallel+0x12972c) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#2 matrix_multiplication(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned int, unsigned int) /proc/self/cwd/check/TestHighsParallel.cpp:218:5 (TestHighsParallel+0x12972c)
#3 C_A_T_C_H_T_E_S_T_0() /proc/self/cwd/check/TestHighsParallel.cpp:226:3 (TestHighsParallel+0x12988f) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#4 Catch::TestInvokerAsFunction::invoke() const /proc/self/cwd/extern/catch.hpp:15015:46 (liblibtest_Ulib.so+0xae0fd) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#5 Catch::TestCase::invoke() const /proc/self/cwd/extern/catch.hpp:14853:39 (liblibtest_Ulib.so+0xa1af0) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#6 Catch::RunContext::invokeActiveTestCase() /proc/self/cwd/extern/catch.hpp:13741:21 (liblibtest_Ulib.so+0xa1af0)
#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>>&) /proc/self/cwd/extern/catch.hpp:13710:7 (liblibtest_Ulib.so+0x9eb5b) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#8 Catch::RunContext::runTest(Catch::TestCase const&) /proc/self/cwd/extern/catch.hpp:13477:5 (liblibtest_Ulib.so+0x9d7d6) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#9 Catch::(anonymous namespace)::TestGroup::execute() /proc/self/cwd/extern/catch.hpp:14040:29 (liblibtest_Ulib.so+0xa6f88) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#10 Catch::Session::runInternal() /proc/self/cwd/extern/catch.hpp:14238:31 (liblibtest_Ulib.so+0xa6f88)
#11 Catch::Session::run() /proc/self/cwd/extern/catch.hpp:14202:18 (liblibtest_Ulib.so+0xa5891) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#12 int Catch::Session::run<char>(int, char const* const*) /proc/self/cwd/extern/catch.hpp:13924:39 (liblibtest_Ulib.so+0xccd46) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#13 main /proc/self/cwd/extern/catch.hpp:18157:27 (liblibtest_Ulib.so+0xccd46)
Previous write of size 8 at 0x72600001c400 by thread T12:
#0 matrix_multiplication_highs(unsigned int)::$_3::operator()(int, int) const /proc/self/cwd/check/TestHighsParallel.cpp:164:19 (TestHighsParallel+0x12bb3f) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#1 void highs::parallel::for_each<matrix_multiplication_highs(unsigned int)::$_3&>(int, int, matrix_multiplication_highs(unsigned int)::$_3&, int) /proc/self/cwd/highs/parallel/HighsParallel.h:119:5 (TestHighsParallel+0x12bb3f)
#2 void highs::parallel::for_each<matrix_multiplication_highs(unsigned int)::$_3&>(int, int, matrix_multiplication_highs(unsigned int)::$_3&, int)::'lambda'()::operator()() const /proc/self/cwd/highs/parallel/HighsParallel.h:114:9 (TestHighsParallel+0x12bd18) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#3 HighsTask::Callable<void highs::parallel::for_each<matrix_multiplication_highs(unsigned int)::$_3&>(int, int, matrix_multiplication_highs(unsigned int)::$_3&, int)::'lambda'()>::operator()() /proc/self/cwd/highs/parallel/HighsTask.h:52:7 (TestHighsParallel+0x12bd18)
#4 HighsTask::run(HighsSplitDeque*) /proc/self/cwd/highs/parallel/HighsTask.h:84:21 (TestHighsParallel+0x12ccc3) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#5 HighsSplitDeque::runStolenTask(HighsTask*) /proc/self/cwd/highs/parallel/HighsSplitDeque.h:478:38 (TestHighsParallel+0x12ccc3)
#6 HighsTaskExecutor::run_worker(int, HighsTaskExecutor*) /proc/self/cwd/highs/parallel/HighsTaskExecutor.h:98:21 (TestHighsParallel+0x12e73e) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#7 void std::__invoke_impl<void, void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>(std::__invoke_other, void (*&&)(int, HighsTaskExecutor*), int&&, HighsTaskExecutor*&&) /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/invoke.h:63:14 (TestHighsParallel+0x12f8a9) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#8 std::__invoke_result<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>::type std::__invoke<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>(void (*&&)(int, HighsTaskExecutor*), int&&, HighsTaskExecutor*&&) /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/invoke.h:98:14 (TestHighsParallel+0x12f8a9)
#9 void std::thread::_Invoker<std::tuple<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>>::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/std_thread.h:303:13 (TestHighsParallel+0x12f8a9)
#10 std::thread::_Invoker<std::tuple<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>>::operator()() /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/std_thread.h:310:11 (TestHighsParallel+0x12f8a9)
#11 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>>>::_M_run() /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/std_thread.h:255:13 (TestHighsParallel+0x12f8a9)
#12 <null> <null> (libstdc++.so.6+0xe6d63) (BuildId: 96c2652d0588b7979060cdc3d0bdb0fbcfdecc9a)
Thread T12 (tid=30, running) created by main thread at:
#0 pthread_create <null> (TestHighsParallel+0xa4295) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) <null> (libstdc++.so.6+0xe6e38) (BuildId: 96c2652d0588b7979060cdc3d0bdb0fbcfdecc9a)
#2 HighsTaskExecutor::HighsTaskExecutor(int) /proc/self/cwd/highs/parallel/HighsTaskExecutor.h:126:21 (TestHighsParallel+0x12e1d3) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#3 HighsTaskExecutor::initialize(int) /proc/self/cwd/highs/parallel/HighsTaskExecutor.h:165:11 (TestHighsParallel+0x129844) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#4 highs::parallel::initialize_scheduler(int) /proc/self/cwd/highs/parallel/HighsParallel.h:28:3 (TestHighsParallel+0x129844)
#5 C_A_T_C_H_T_E_S_T_0() /proc/self/cwd/check/TestHighsParallel.cpp:224:3 (TestHighsParallel+0x129844)
#6 Catch::TestInvokerAsFunction::invoke() const /proc/self/cwd/extern/catch.hpp:15015:46 (liblibtest_Ulib.so+0xae0fd) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#7 Catch::TestCase::invoke() const /proc/self/cwd/extern/catch.hpp:14853:39 (liblibtest_Ulib.so+0xa1af0) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#8 Catch::RunContext::invokeActiveTestCase() /proc/self/cwd/extern/catch.hpp:13741:21 (liblibtest_Ulib.so+0xa1af0)
#9 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>>&) /proc/self/cwd/extern/catch.hpp:13710:7 (liblibtest_Ulib.so+0x9eb5b) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#10 Catch::RunContext::runTest(Catch::TestCase const&) /proc/self/cwd/extern/catch.hpp:13477:5 (liblibtest_Ulib.so+0x9d7d6) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#11 Catch::(anonymous namespace)::TestGroup::execute() /proc/self/cwd/extern/catch.hpp:14040:29 (liblibtest_Ulib.so+0xa6f88) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#12 Catch::Session::runInternal() /proc/self/cwd/extern/catch.hpp:14238:31 (liblibtest_Ulib.so+0xa6f88)
#13 Catch::Session::run() /proc/self/cwd/extern/catch.hpp:14202:18 (liblibtest_Ulib.so+0xa5891) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#14 int Catch::Session::run<char>(int, char const* const*) /proc/self/cwd/extern/catch.hpp:13924:39 (liblibtest_Ulib.so+0xccd46) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#15 main /proc/self/cwd/extern/catch.hpp:18157:27 (liblibtest_Ulib.so+0xccd46)
SUMMARY: ThreadSanitizer: data race (/usr/local/google/home/corentinl/.cache/bazel/_bazel_corentinl/4a2721af6f58579727dc4fe79c840cbc/execroot/_main/bazel-out/k8-fastbuild/bin/TestHighsParallel+0xa2e36) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d) in free
==================
==================
WARNING: ThreadSanitizer: data race (pid=12)
Write of size 8 at 0x726000000120 by main thread:
#0 free <null> (TestHighsParallel+0xa2e36) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#1 deallocate_matrix() /proc/self/cwd/check/matrix_multiplication.hpp:36:3 (TestHighsParallel+0x129520) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#2 matrix_multiplication(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned int, unsigned int) /proc/self/cwd/check/TestHighsParallel.cpp:218:5 (TestHighsParallel+0x129520)
#3 C_A_T_C_H_T_E_S_T_0() /proc/self/cwd/check/TestHighsParallel.cpp:226:3 (TestHighsParallel+0x12988f) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#4 Catch::TestInvokerAsFunction::invoke() const /proc/self/cwd/extern/catch.hpp:15015:46 (liblibtest_Ulib.so+0xae0fd) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#5 Catch::TestCase::invoke() const /proc/self/cwd/extern/catch.hpp:14853:39 (liblibtest_Ulib.so+0xa1af0) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#6 Catch::RunContext::invokeActiveTestCase() /proc/self/cwd/extern/catch.hpp:13741:21 (liblibtest_Ulib.so+0xa1af0)
#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>>&) /proc/self/cwd/extern/catch.hpp:13710:7 (liblibtest_Ulib.so+0x9eb5b) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#8 Catch::RunContext::runTest(Catch::TestCase const&) /proc/self/cwd/extern/catch.hpp:13477:5 (liblibtest_Ulib.so+0x9d7d6) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#9 Catch::(anonymous namespace)::TestGroup::execute() /proc/self/cwd/extern/catch.hpp:14040:29 (liblibtest_Ulib.so+0xa6f88) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#10 Catch::Session::runInternal() /proc/self/cwd/extern/catch.hpp:14238:31 (liblibtest_Ulib.so+0xa6f88)
#11 Catch::Session::run() /proc/self/cwd/extern/catch.hpp:14202:18 (liblibtest_Ulib.so+0xa5891) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#12 int Catch::Session::run<char>(int, char const* const*) /proc/self/cwd/extern/catch.hpp:13924:39 (liblibtest_Ulib.so+0xccd46) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#13 main /proc/self/cwd/extern/catch.hpp:18157:27 (liblibtest_Ulib.so+0xccd46)
Previous read of size 8 at 0x726000000120 by thread T12:
#0 void highs::parallel::for_each<matrix_multiplication_highs(unsigned int)::$_3&>(int, int, matrix_multiplication_highs(unsigned int)::$_3&, int) /proc/self/cwd/check/TestHighsParallel.cpp (TestHighsParallel+0x12ba6b) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#1 void highs::parallel::for_each<matrix_multiplication_highs(unsigned int)::$_3&>(int, int, matrix_multiplication_highs(unsigned int)::$_3&, int)::'lambda'()::operator()() const /proc/self/cwd/highs/parallel/HighsParallel.h:114:9 (TestHighsParallel+0x12bd18) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#2 HighsTask::Callable<void highs::parallel::for_each<matrix_multiplication_highs(unsigned int)::$_3&>(int, int, matrix_multiplication_highs(unsigned int)::$_3&, int)::'lambda'()>::operator()() /proc/self/cwd/highs/parallel/HighsTask.h:52:7 (TestHighsParallel+0x12bd18)
#3 HighsTask::run(HighsSplitDeque*) /proc/self/cwd/highs/parallel/HighsTask.h:84:21 (TestHighsParallel+0x12ccc3) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#4 HighsSplitDeque::runStolenTask(HighsTask*) /proc/self/cwd/highs/parallel/HighsSplitDeque.h:478:38 (TestHighsParallel+0x12ccc3)
#5 HighsTaskExecutor::run_worker(int, HighsTaskExecutor*) /proc/self/cwd/highs/parallel/HighsTaskExecutor.h:98:21 (TestHighsParallel+0x12e73e) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#6 void std::__invoke_impl<void, void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>(std::__invoke_other, void (*&&)(int, HighsTaskExecutor*), int&&, HighsTaskExecutor*&&) /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/invoke.h:63:14 (TestHighsParallel+0x12f8a9) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#7 std::__invoke_result<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>::type std::__invoke<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>(void (*&&)(int, HighsTaskExecutor*), int&&, HighsTaskExecutor*&&) /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/invoke.h:98:14 (TestHighsParallel+0x12f8a9)
#8 void std::thread::_Invoker<std::tuple<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>>::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/std_thread.h:303:13 (TestHighsParallel+0x12f8a9)
#9 std::thread::_Invoker<std::tuple<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>>::operator()() /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/std_thread.h:310:11 (TestHighsParallel+0x12f8a9)
#10 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>>>::_M_run() /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/std_thread.h:255:13 (TestHighsParallel+0x12f8a9)
#11 <null> <null> (libstdc++.so.6+0xe6d63) (BuildId: 96c2652d0588b7979060cdc3d0bdb0fbcfdecc9a)
Thread T12 (tid=30, running) created by main thread at:
#0 pthread_create <null> (TestHighsParallel+0xa4295) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) <null> (libstdc++.so.6+0xe6e38) (BuildId: 96c2652d0588b7979060cdc3d0bdb0fbcfdecc9a)
#2 HighsTaskExecutor::HighsTaskExecutor(int) /proc/self/cwd/highs/parallel/HighsTaskExecutor.h:126:21 (TestHighsParallel+0x12e1d3) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#3 HighsTaskExecutor::initialize(int) /proc/self/cwd/highs/parallel/HighsTaskExecutor.h:165:11 (TestHighsParallel+0x129844) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#4 highs::parallel::initialize_scheduler(int) /proc/self/cwd/highs/parallel/HighsParallel.h:28:3 (TestHighsParallel+0x129844)
#5 C_A_T_C_H_T_E_S_T_0() /proc/self/cwd/check/TestHighsParallel.cpp:224:3 (TestHighsParallel+0x129844)
#6 Catch::TestInvokerAsFunction::invoke() const /proc/self/cwd/extern/catch.hpp:15015:46 (liblibtest_Ulib.so+0xae0fd) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#7 Catch::TestCase::invoke() const /proc/self/cwd/extern/catch.hpp:14853:39 (liblibtest_Ulib.so+0xa1af0) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#8 Catch::RunContext::invokeActiveTestCase() /proc/self/cwd/extern/catch.hpp:13741:21 (liblibtest_Ulib.so+0xa1af0)
#9 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>>&) /proc/self/cwd/extern/catch.hpp:13710:7 (liblibtest_Ulib.so+0x9eb5b) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#10 Catch::RunContext::runTest(Catch::TestCase const&) /proc/self/cwd/extern/catch.hpp:13477:5 (liblibtest_Ulib.so+0x9d7d6) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#11 Catch::(anonymous namespace)::TestGroup::execute() /proc/self/cwd/extern/catch.hpp:14040:29 (liblibtest_Ulib.so+0xa6f88) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#12 Catch::Session::runInternal() /proc/self/cwd/extern/catch.hpp:14238:31 (liblibtest_Ulib.so+0xa6f88)
#13 Catch::Session::run() /proc/self/cwd/extern/catch.hpp:14202:18 (liblibtest_Ulib.so+0xa5891) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#14 int Catch::Session::run<char>(int, char const* const*) /proc/self/cwd/extern/catch.hpp:13924:39 (liblibtest_Ulib.so+0xccd46) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#15 main /proc/self/cwd/extern/catch.hpp:18157:27 (liblibtest_Ulib.so+0xccd46)
SUMMARY: ThreadSanitizer: data race (/usr/local/google/home/corentinl/.cache/bazel/_bazel_corentinl/4a2721af6f58579727dc4fe79c840cbc/execroot/_main/bazel-out/k8-fastbuild/bin/TestHighsParallel+0xa2e36) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d) in free
==================
==================
WARNING: ThreadSanitizer: data race (pid=12)
Write of size 8 at 0x726000000920 by main thread:
#0 free <null> (TestHighsParallel+0xa2e36) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#1 deallocate_matrix() /proc/self/cwd/check/matrix_multiplication.hpp:38:3 (TestHighsParallel+0x12954e) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#2 matrix_multiplication(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned int, unsigned int) /proc/self/cwd/check/TestHighsParallel.cpp:218:5 (TestHighsParallel+0x12954e)
#3 C_A_T_C_H_T_E_S_T_0() /proc/self/cwd/check/TestHighsParallel.cpp:226:3 (TestHighsParallel+0x12988f) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#4 Catch::TestInvokerAsFunction::invoke() const /proc/self/cwd/extern/catch.hpp:15015:46 (liblibtest_Ulib.so+0xae0fd) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#5 Catch::TestCase::invoke() const /proc/self/cwd/extern/catch.hpp:14853:39 (liblibtest_Ulib.so+0xa1af0) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#6 Catch::RunContext::invokeActiveTestCase() /proc/self/cwd/extern/catch.hpp:13741:21 (liblibtest_Ulib.so+0xa1af0)
#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>>&) /proc/self/cwd/extern/catch.hpp:13710:7 (liblibtest_Ulib.so+0x9eb5b) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#8 Catch::RunContext::runTest(Catch::TestCase const&) /proc/self/cwd/extern/catch.hpp:13477:5 (liblibtest_Ulib.so+0x9d7d6) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#9 Catch::(anonymous namespace)::TestGroup::execute() /proc/self/cwd/extern/catch.hpp:14040:29 (liblibtest_Ulib.so+0xa6f88) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#10 Catch::Session::runInternal() /proc/self/cwd/extern/catch.hpp:14238:31 (liblibtest_Ulib.so+0xa6f88)
#11 Catch::Session::run() /proc/self/cwd/extern/catch.hpp:14202:18 (liblibtest_Ulib.so+0xa5891) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#12 int Catch::Session::run<char>(int, char const* const*) /proc/self/cwd/extern/catch.hpp:13924:39 (liblibtest_Ulib.so+0xccd46) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#13 main /proc/self/cwd/extern/catch.hpp:18157:27 (liblibtest_Ulib.so+0xccd46)
Previous read of size 8 at 0x726000000920 by thread T12:
#0 void highs::parallel::for_each<matrix_multiplication_highs(unsigned int)::$_3&>(int, int, matrix_multiplication_highs(unsigned int)::$_3&, int) /proc/self/cwd/check/TestHighsParallel.cpp (TestHighsParallel+0x12baa4) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#1 void highs::parallel::for_each<matrix_multiplication_highs(unsigned int)::$_3&>(int, int, matrix_multiplication_highs(unsigned int)::$_3&, int)::'lambda'()::operator()() const /proc/self/cwd/highs/parallel/HighsParallel.h:114:9 (TestHighsParallel+0x12bd18) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#2 HighsTask::Callable<void highs::parallel::for_each<matrix_multiplication_highs(unsigned int)::$_3&>(int, int, matrix_multiplication_highs(unsigned int)::$_3&, int)::'lambda'()>::operator()() /proc/self/cwd/highs/parallel/HighsTask.h:52:7 (TestHighsParallel+0x12bd18)
#3 HighsTask::run(HighsSplitDeque*) /proc/self/cwd/highs/parallel/HighsTask.h:84:21 (TestHighsParallel+0x12ccc3) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#4 HighsSplitDeque::runStolenTask(HighsTask*) /proc/self/cwd/highs/parallel/HighsSplitDeque.h:478:38 (TestHighsParallel+0x12ccc3)
#5 HighsTaskExecutor::run_worker(int, HighsTaskExecutor*) /proc/self/cwd/highs/parallel/HighsTaskExecutor.h:98:21 (TestHighsParallel+0x12e73e) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#6 void std::__invoke_impl<void, void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>(std::__invoke_other, void (*&&)(int, HighsTaskExecutor*), int&&, HighsTaskExecutor*&&) /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/invoke.h:63:14 (TestHighsParallel+0x12f8a9) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#7 std::__invoke_result<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>::type std::__invoke<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>(void (*&&)(int, HighsTaskExecutor*), int&&, HighsTaskExecutor*&&) /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/invoke.h:98:14 (TestHighsParallel+0x12f8a9)
#8 void std::thread::_Invoker<std::tuple<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>>::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/std_thread.h:303:13 (TestHighsParallel+0x12f8a9)
#9 std::thread::_Invoker<std::tuple<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>>::operator()() /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/std_thread.h:310:11 (TestHighsParallel+0x12f8a9)
#10 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(int, HighsTaskExecutor*), int, HighsTaskExecutor*>>>::_M_run() /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/std_thread.h:255:13 (TestHighsParallel+0x12f8a9)
#11 <null> <null> (libstdc++.so.6+0xe6d63) (BuildId: 96c2652d0588b7979060cdc3d0bdb0fbcfdecc9a)
Thread T12 (tid=30, running) created by main thread at:
#0 pthread_create <null> (TestHighsParallel+0xa4295) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) <null> (libstdc++.so.6+0xe6e38) (BuildId: 96c2652d0588b7979060cdc3d0bdb0fbcfdecc9a)
#2 HighsTaskExecutor::HighsTaskExecutor(int) /proc/self/cwd/highs/parallel/HighsTaskExecutor.h:126:21 (TestHighsParallel+0x12e1d3) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#3 HighsTaskExecutor::initialize(int) /proc/self/cwd/highs/parallel/HighsTaskExecutor.h:165:11 (TestHighsParallel+0x129844) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d)
#4 highs::parallel::initialize_scheduler(int) /proc/self/cwd/highs/parallel/HighsParallel.h:28:3 (TestHighsParallel+0x129844)
#5 C_A_T_C_H_T_E_S_T_0() /proc/self/cwd/check/TestHighsParallel.cpp:224:3 (TestHighsParallel+0x129844)
#6 Catch::TestInvokerAsFunction::invoke() const /proc/self/cwd/extern/catch.hpp:15015:46 (liblibtest_Ulib.so+0xae0fd) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#7 Catch::TestCase::invoke() const /proc/self/cwd/extern/catch.hpp:14853:39 (liblibtest_Ulib.so+0xa1af0) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#8 Catch::RunContext::invokeActiveTestCase() /proc/self/cwd/extern/catch.hpp:13741:21 (liblibtest_Ulib.so+0xa1af0)
#9 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>>&) /proc/self/cwd/extern/catch.hpp:13710:7 (liblibtest_Ulib.so+0x9eb5b) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#10 Catch::RunContext::runTest(Catch::TestCase const&) /proc/self/cwd/extern/catch.hpp:13477:5 (liblibtest_Ulib.so+0x9d7d6) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#11 Catch::(anonymous namespace)::TestGroup::execute() /proc/self/cwd/extern/catch.hpp:14040:29 (liblibtest_Ulib.so+0xa6f88) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#12 Catch::Session::runInternal() /proc/self/cwd/extern/catch.hpp:14238:31 (liblibtest_Ulib.so+0xa6f88)
#13 Catch::Session::run() /proc/self/cwd/extern/catch.hpp:14202:18 (liblibtest_Ulib.so+0xa5891) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#14 int Catch::Session::run<char>(int, char const* const*) /proc/self/cwd/extern/catch.hpp:13924:39 (liblibtest_Ulib.so+0xccd46) (BuildId: 24714abc09803858fbac3cd9bd058dd1fdab4169)
#15 main /proc/self/cwd/extern/catch.hpp:18157:27 (liblibtest_Ulib.so+0xccd46)
SUMMARY: ThreadSanitizer: data race (/usr/local/google/home/corentinl/.cache/bazel/_bazel_corentinl/4a2721af6f58579727dc4fe79c840cbc/execroot/_main/bazel-out/k8-fastbuild/bin/TestHighsParallel+0xa2e36) (BuildId: dd3f0521480273190c0a236a5911e32b3193446d) in free
==================
===============================================================================
All tests passed (1 assertion in 2 test cases)
ThreadSanitizer: reported 4 warnings
We spot a data race internally and fix it, here a way to reproduce it (patch incoming !)
First need to enable
TestHighsParallelin bazel....note: I also increase the number of thread just in case to easily reproduce it (not sure was needed)
Protocol
First gcc 15.2.0 can't build HiGHS, have to force usage of clang (19.1.7)
note: could be related to llvm/llvm-project#156667
note: I'm using bazel 9.0.0
Trace:
on this 100 runs, get 3 times a bazel trace logs...
Fix
note: PR soon !