[PATCH 0/2] lib/assoc_array: fix root-shortcut split lookup regression, add KUnit tests

From: William Chuang

Date: Mon Nov 16 2026 - 00:41:30 EST


This series adds a KUnit test suite for lib/assoc_array.c and fixes a
lookup bug that suite exposes.

When a root shortcut is split at the first level-segment boundary, the
replacement node is installed one segment too shallow. Lookups then walk
the tree at the wrong depth, so a fraction of previously inserted keys can
no longer be found, even though they remain in the array.

Patch 1 adds the test suite; it passes on mainline. Patch 2 fixes the
split path in assoc_array_insert() and adds a regression test that fails
without the fix, keeping the series bisection-clean.

The fix was checked by exhaustive fan-out enumeration, randomized stress
runs, and KASAN; the patch 2 commit message describes the mechanism in
detail.

William Chuang (2):
lib/assoc_array: add KUnit test suite
lib/assoc_array: fix lookups after splitting a root shortcut

lib/Kconfig.debug | 17 +
lib/assoc_array.c | 3 +-
lib/tests/Makefile | 1 +
lib/tests/assoc_array_kunit.c | 991 ++++++++++++++++++++++++++++++++++
4 files changed, 1011 insertions(+), 1 deletion(-)
create mode 100644 lib/tests/assoc_array_kunit.c

--
2.39.1