khizmax / libcds

A C++ library of Concurrent Data Structures
http://libcds.sourceforge.net/doc/cds-api/index.html
Boost Software License 1.0
2.57k stars 360 forks source link

FeldmanHashMap find function NULL pointer #151

Closed 9MW closed 4 years ago

9MW commented 4 years ago

When use find function the value pointer occasionally return null,but when inspect it value it's isn't null. like if (posmap.find(xel, [&](PosHash::value_type& val) { const var& vx = val.second; if(vx==NULL){ vx->insert(cdid); } val.second->insert(cdid); })) when vx==NULL reinsert still get success.

khizmax commented 4 years ago

find only guarantees that val is valid in the functor and give no warranties about its fields. In multi-thread environment you should manage val fields yourself. This applies to any container in libcds.

9MW commented 4 years ago

try to add some lock

9MW commented 4 years ago

solved by while(true){ if(vx!=NULL){dosomething()} }