From fb5216ff9811001b9e2b5d200f4c266afb17705a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 7 Jan 2026 18:18:21 -0500 Subject: [PATCH] xo-arena: verify SM4.1.2 for DArenaHashMap.verify_ok --- include/xo/arena/DArenaHashMap.hpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/xo/arena/DArenaHashMap.hpp b/include/xo/arena/DArenaHashMap.hpp index a37c228..7e03a1e 100644 --- a/include/xo/arena/DArenaHashMap.hpp +++ b/include/xo/arena/DArenaHashMap.hpp @@ -527,6 +527,29 @@ namespace xo { } } + /* SM4.1.2: if control_[i] is non-sentinel, all slots in range [h .. i] are non-empty, + * where h = (hash_(slots_[i].first) >> 7) & (n_slot_ - 1) + */ + for (size_type i = 0; i < n_slot_; ++i) { + uint8_t c = control_[i]; + if ((c != c_empty_slot) && (c != c_tombstone)) { + size_type h = (hash_(slots_[i].first) >> 7) & (n_slot_ - 1); + size_type j = h; + while (j != i) { + uint8_t cj = control_[j]; + if ((cj == c_empty_slot) || (cj == c_tombstone)) { + return policy.report_error(log, + c_self, ": expect non-empty slot in probe range [h..i]", + xtag("i", i), + xtag("h", h), + xtag("j", j), + xtag("control[j]", cj)); + } + j = (j + 1) & (n_slot_ - 1); + } + } + } + return true; } }