Test environment gcc4.8.2
??
Iterator Find (const key_type& k);
Const_iterator Find (const key_type& k) const;
??
Unordered_map has two corresponding find functions I infer that the second one is safe and the first one is not thread safe.
??
Auto iter = _map.find (key)
Core in OpenMP multithreaded environment, thanks to Glog for error message output
??
***? aborted?at?1412933723? (unix?time)? Try? " [Email protected] "? if?you?are?using? gnu?date?***
Pc:[email protected]??????????? 0x8d1d65?std::equal_to<>::operator () ()
***? SIGSEGV? (@0x8)? Received?by? pid?3216? (tid?0x7f7c3902d700)? From? pid?8;? stack?trace:?***
[Email protected]????? 0x7f7c4b769150? (unknown)
[Email protected]??????????? 0x8d1d65?std::equal_to<>::operator () ()
[Email protected]??????????? 0x8e231b?std::__detail::_equal_helper<>::_s_equals ()
[Email protected]??????????? 0x8dbbb0?std::__detail::_hashtable_base<>::_m_equals ()
[Email protected]??????????? 0x8d1e63?std::_hashtable<>::_m_find_before_node ()
[Email protected]??????????? 0x8c432e?std::_hashtable<>::_m_find_node ()
[Email protected]??????????? 0x8b2bca?std::_hashtable<>::find ()
[Email protected]??????????? 0x89adcd?std::unordered_map<>::find ()
[Email protected]??????????? 0x87af21?gezi::lrumap<>::find ()
[Email protected]??????????? 0x85c6ab?gezi::timermap<>::count ()
[Email protected]??????????? 0x7ee705?run ()
[Email protected]??????????? 0x7f1893?_z3runv._omp_fn.3
[Email protected]????? 0x7f7c4a65641a?gomp_thread_start
[Email protected]????? 0x7f7c4b7611c1?start_thread
[Email protected]????? 0x7f7c49b6c0ad?__clone
Segmentation?fault
??
??
Since I may need to modify iter->second, I cannot use const_iterator
Increase
Iterator Iter;
#pragma omp critical
iter = _map.find (key);
??
The program is running normally.
is the map find thread-safe?