Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

tbb::concurrent_hash_map throws SIGSEGV

rafaelcidade
Beginner
249 Views

I'm running a small program built using TBB on Windows with mingw32. It does a parallel_for. Inside the parallel_for my object makes changes to a concurrent_hash_map object. It starts running but later throws a SIGSEGV when I try to use an accessor. I don't know where the problem is.

My object:

class Foobar
{
public:
Foobar(FoobarParent* rw) : _rw(rw)
{
_fooMap = &_rw->randomWalkers();
}

void operator() (const tbb::blocked_range&r ) const
{
for(size_t i = r.begin(); i != r.end(); ++i)
{
apply(i);
}
}

private:
void apply(int i) const
{
pointMap_t::accessor a;
_fooMap->find(a, i);
Point3D current = a->second;
Point3D next = _rw->getNext(current);

if (!_rw->hasConstraint(next))
{
return;
}

a->second = next;
}

FoobarParent* _rw;
pointMap_t* _fooMap;
};

pointMap_t is defined as:

typedef tbb::concurrent_hash_map pointMap_t;

Can someone shed a light on this issue? I'm new to TBB. The signal is thrown when the apply method calls a->second.
0 Kudos
2 Replies
Anton_M_Intel
Employee
249 Views
Did you try to build in debug? You will probably see a failed assertion instead of segmentation error.
One possible reason of the issue is that you assume that the item exists by not checking the return status of find() operation, but in reality it seems not.
0 Kudos
RafSchietekat
Valued Contributor III
249 Views
Evaluate the return value of find() and act accordingly.
0 Kudos
Reply