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
According to iterator invalidation rules, rehashing invalidates the iterators of unordered_map, which may occur during the execution of the callback (it->second();). I didn't encounter any error about "invalid iterator" in my application, but I think it would be better to fix this,
Callback cb = nullptr;
mu_.lock();
auto it = callbacks_.find(timestamp);
if (it != callbacks_.end()) {
cb = it->second;
CHECK(cb);
callbacks_.erase(it);
}
mu_.unlock();
if (cb) cb();
Let me add more context. ZPush/ZPull insert new elements to callbacks_, while RunCallback eliminates some elements from callbacks_ and it is called inside Process on another thread created by Customer at this line and this line.
Is KVWorker::RunCallback thread safe?
According to iterator invalidation rules, rehashing invalidates the iterators of
unordered_map
, which may occur during the execution of the callback (it->second();
). I didn't encounter any error about "invalid iterator" in my application, but I think it would be better to fix this,cc @eric-haibin-lin
The text was updated successfully, but these errors were encountered: