You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've faced odd crash using parallel_scan over range object that has some logic inside its destructor. It seems that destructor of range sometimes called on not yet constructed range object.
It happens not 100% times, but there is a minimal reproducible example I managed to get (ensure asserts are on):
#include <cassert>
#include <vector>
#include <tbb/parallel_reduce.h>
#include <tbb/parallel_scan.h>
int main()
{
std::vector <int> vec;
const int len = 34479;
struct non_trivial_range : tbb::blocked_range <decltype(vec)::iterator>
{
using non_trivial_range::blocked_range::blocked_range;
~non_trivial_range()
{
assert( cookie == 0xc001c001 );
cookie = 0xdeadbeef;
}
unsigned cookie = 0xc001c001;
};
vec.assign( len, 1 );
// this works fine
int s = tbb::parallel_reduce( non_trivial_range{ vec.begin(), vec.end() }, 0, [&]( const auto & rng, int acc )
{
for (int p : rng) acc += p; // work is irrelevant
return acc;
}, std::plus<>() );
assert( s == len );
// this fails eventually
for (int i = 0; i < 1000; ++i)
{
s = tbb::parallel_scan( non_trivial_range{ vec.begin(), vec.end() }, 0, [&]( const auto & rng, int acc, auto is_final )
{
for (int p : rng) acc += p; // work is irrelevant
return acc;
}, std::plus<>() );
assert( s == len );
}
return s;
}
We are still looking into why the object is left uninitialized. Meanwhile, I hope that you are able to use the workaround (even a simple if (m_parent) check would work).
Hi,
I've faced odd crash using parallel_scan over range object that has some logic inside its destructor. It seems that destructor of range sometimes called on not yet constructed range object.
It happens not 100% times, but there is a minimal reproducible example I managed to get (ensure asserts are on):
tbb.cpp.txt
Tested on:
Is there a problem inside my code?
Regards,
Slava
The text was updated successfully, but these errors were encountered: