ASSERT in simple Parallel_for

ASSERT in simple Parallel_for


I am starting out with TBB, and whist having success in some areas, and seeing dramatic performance improvements, I have come a across an issue, I am struggling to understand.

I have an unordered map:-

typedef tbb::concurrent_unordered_map<CString, CGeoStation *, UTCHashCompareNoCase> CGeoStationConcurrentUnorderedMap;

and my variable based on this is

CGeoStationConcurrentUnorderedMap * m_pStations;

I have an issue when running the parallel_for. 

Note that the work done is commented out, in essence it is an empty loop.

 tbb::parallel_for(m_pStations->range(), [&] (CGeoStationConcurrentUnorderedMap::const_range_type & range)
 for(auto it = range.begin(); it != range.end(); it++)
 //if(WildCmpNoCase((LPTSTR)(LPCTSTR) strSearch, (LPTSTR)(LPCTSTR) it->second->GetLabel()))
 // m_theMatch.push_back(it->second);

I get the assert 'my_begin_node is after my_midpoint_node' at line 822 in _concurrent_unordered_impl.h

else {
 sokey_t mid_key = solist_t::get_safe_order_key(my_midpoint_node);
__TBB_ASSERT( begin_key < mid_key, "my_begin_node is after my_midpoint_node" );
 __TBB_ASSERT( mid_key <= end_key, "my_midpoint_node is after my_end_node" );
#endif // TBB_USE_ASSERT

I am not sure what the assert means, or what could be causing it, or what I need to do to fix my code.



6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Thanks for your report! Can you isolate the problem into a simple reproducer test? Is this loop executed concurrently to other operations over this map?
Which OS/compilers of what version do you use?

Hi Anton,

Its probably a bit difficult to isolate. It works well when I have 3K item in the map, but when I run a larger dataset with 20K items, it has the problem.

I use Windows 7, MSVS 2012, but using the VS2010 libraries.

I am not aware of any other looping with the map, BUT, as this map also feeds a GIS style map view as well, it is possible that a background paint utilising the map might be occurring, but I will disable that, and test.


Hi Anton,

I have disabled the GIS map drawing code, so I am pretty sure that there is no other looping of the map of stations, and I am still getting the assert.


I have built a simple MFC app. It seems to be OK in 32 bit, but I get asserts in 64 bit. I have attached the file.

I am probably at this stage looking as to what may cause the assert.


Downloadapplication/zip tbbtest.zip261.99 KB

I have solved the problem by moving to concurrenthashmap


Leave a Comment

Please sign in to add a comment. Not a member? Join today