From a7fec616cdbb4ff8bb3cee6767dea862766c321d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 7 Jan 2026 18:16:38 -0500 Subject: [PATCH] xo-arena: verify SM4.1.1 in DArenaHashMap.verify_ok --- include/xo/arena/DArenaHashMap.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/xo/arena/DArenaHashMap.hpp b/include/xo/arena/DArenaHashMap.hpp index 7c1dfbc..a37c228 100644 --- a/include/xo/arena/DArenaHashMap.hpp +++ b/include/xo/arena/DArenaHashMap.hpp @@ -512,6 +512,21 @@ namespace xo { } } + /* SM4.1.1: if control_[i] is non-sentinel, control_[i] = hash_(slots_[i].first) & 0x7f */ + for (size_type i = 0; i < n_slot_; ++i) { + uint8_t c = control_[i]; + if ((c != c_empty_slot) && (c != c_tombstone)) { + uint8_t expected_h2 = hash_(slots_[i].first) & 0x7f; + if (c != expected_h2) { + return policy.report_error(log, + c_self, ": expect control[i] = hash(key) & 0x7f", + xtag("i", i), + xtag("control[i]", c), + xtag("expected_h2", expected_h2)); + } + } + } + return true; } }