Commit f3930359 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook Github Bot

Fix : iterating through ConcurrentHashMapSIMD results in infinite loop

Summary: Fix : iterating through ConcurrentHashMapSIMD results in infinite loop

Reviewed By: nbronson

Differential Revision: D16923826

fbshipit-source-id: c8b98ef13034240c162c155cf0e5c3f097b73c7f
parent 8973236c
...@@ -1088,6 +1088,7 @@ class alignas(64) SIMDTable { ...@@ -1088,6 +1088,7 @@ class alignas(64) SIMDTable {
++chunk_idx_; ++chunk_idx_;
} }
if (chunk_idx_ >= chunk_count_) { if (chunk_idx_ >= chunk_count_) {
node_ = nullptr;
break; break;
} }
DCHECK(chunks_); DCHECK(chunks_);
......
...@@ -811,6 +811,22 @@ TYPED_TEST_P(ConcurrentHashMapTest, IteratorMove) { ...@@ -811,6 +811,22 @@ TYPED_TEST_P(ConcurrentHashMapTest, IteratorMove) {
ASSERT_EQ(foo2.it->second, v); ASSERT_EQ(foo2.it->second, v);
} }
TYPED_TEST_P(ConcurrentHashMapTest, IteratorLoop) {
CHM<std::string, int> map;
static constexpr size_t kNum = 4000;
for (size_t i = 0; i < kNum; ++i) {
map.insert(to<std::string>(i), i);
}
size_t count = 0;
for (auto it = map.begin(); it != map.end(); ++it) {
ASSERT_LT(count, kNum);
++count;
}
EXPECT_EQ(count, kNum);
}
REGISTER_TYPED_TEST_CASE_P( REGISTER_TYPED_TEST_CASE_P(
ConcurrentHashMapTest, ConcurrentHashMapTest,
MapTest, MapTest,
...@@ -843,7 +859,8 @@ REGISTER_TYPED_TEST_CASE_P( ...@@ -843,7 +859,8 @@ REGISTER_TYPED_TEST_CASE_P(
UpdateStressTest, UpdateStressTest,
assignStressTest, assignStressTest,
insertStressTest, insertStressTest,
IteratorMove); IteratorMove,
IteratorLoop);
using folly::detail::concurrenthashmap::bucket::BucketTable; using folly::detail::concurrenthashmap::bucket::BucketTable;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment