After I compile the following code
#include <execution>
#include <vector>
#include <iostream>
#include <numeric>
int main()
{
std::vector<char> v(1000000);
for (auto& x: v) x = rand() % 2;
auto rst = std::reduce(
std::execution::par_unseq, v.begin(), v.end(), int(0));
std::cout << rst << "n";
}
with sanitizers, i.e. /usr/opt/gcc-13/bin/g++ -std=gnu++20 -ltbb -g -fno-omit-frame-pointer -fsanitize=address,undefined reduceDebug.cpp -o reduceDebug
, running the executable ./reduceDebug
produces the following:
/usr/include/tbb/parallel_reduce.h:177:32: runtime error: member call on address 0x7fad8c5afb40 which does not point to an object of type 'task'
0x7fad8c5afb40: note: object has invalid vptr
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^~~~~~~~~~~~~~~~~~~~~~~
invalid vptr
/usr/include/tbb/task.h:708:15: runtime error: member call on address 0x7fad8c5afb40 which does not point to an object of type 'task'
0x7fad8c5afb40: note: object has invalid vptr
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^~~~~~~~~~~~~~~~~~~~~~~
invalid vptr
/usr/include/tbb/parallel_reduce.h:178:45: runtime error: member call on address 0x7fad8c5afb40 which does not point to an object of type 'task'
0x7fad8c5afb40: note: object has invalid vptr
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^~~~~~~~~~~~~~~~~~~~~~~
invalid vptr
499845
=================================================================
==5747==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 6168 byte(s) in 3 object(s) allocated from:
#0 0x7fad9142e268 in operator new[](unsigned long) ../../../../gcc-source/libsanitizer/asan/asan_new_delete.cpp:98
#1 0x7fad91137c94 in tbb::internal::arena::arena(tbb::internal::market&, unsigned int, unsigned int) (/lib64/libtbb.so.2+0x22c94) (BuildId: f894fc079c5c7a9a50415a2998216e4421ca0225)
SUMMARY: AddressSanitizer: 6168 byte(s) leaked in 3 allocation(s).
The program runs correctly without sanitization.
Should I be concerned? Some posts seem to suggest these errors are false positive. But considering this is STL and GCC that employs tbb, it is a little hard to believe that there are no solid reasons behind these errors. So, what are they?