merged2978104c5c9cf573 #477 · opened 2026-10-30 11:55 UTC · closed 2026-10-30 12:14 UTC · merged 2026-10-30 12:14 UTC
Imported from GitHub aien-dev/aienux#477, by drakestapleton
Base a525c405ea47e3fe91c19602a6bef6753599d726 · Head dc9a99612b3ab63e82c7cd898d95a682a071144a
Merged on GitHub as b00c728c2443d8931e8e697a25d67f5e20e408ca; reachable from main d01b2f19cccf3e173a6bdb3541813d467f537a76 (observed 2026-11-18T16:35:37Z)
drakestapleton wrote on 2026-10-30 11:55 UTC
Fixes #476
What broke
make -C native/net test with clang 18 stops in native/net/tests/vnet_test.c on
CHECK(s.q[0].used_idx < 70000u); /* wrapped */
simq.used_idx is a uint16_t. 70000 does not fit in 16 bits, so clang 18 reports -Wtautological-constant-out-of-range-compare. The net Makefile builds with -Werror. gcc 13 accepts the same line, which is why it has built since #200.
What the assertion protects
test_datapath exchanges 70,000 frames so the virtio split-virtqueue indices wrap. push_used increments q->used_idx once per RX completion and publishes that value as the 16-bit used-ring index. The comment on the check is wrapped: after 70000 RX completions, starting from 0, that index holds 70000 mod 65536 (4464).
< 70000u cannot observe that. Every value of a uint16_t is below 70000, so the comparison stayed true even when the counter had not moved.
(uint16_t)70000u is that residue. The equality holds when the free-running index has advanced 70000 steps and wrapped at 16 bits. A counter that stayed put, wrapped at the queue size, or was widened and still held the raw count 70000, fails. The frame checks in the loop (EQ(bad, 0)) are unchanged.
make -C native/net test sanitize mutants passes with clang 18.1.3 and with gcc 13.3.0. Both report NET_SECURE_MUTANTS: 30/30 killed. Crumbs were recompiled with the tool pinned in crumb.lock (d0f0b95d); crumb verify is current.
drakestapleton reviewed (COMMENTED) on 2026-10-30 12:05 UTC
Review at head 0d73933a.
Verdict: the fix is correct. It is not merge-ready yet because the branch conflicts with main (mergeable_state dirty). Refresh it (merge main and regenerate the .crumb files), and then it is good to go.
What I checked:
The only hand-written change is in native/net/tests/vnet_test.c (L476-477). It replaces CHECK(s.q[0].used_idx < 70000u), which is always true on a 16-bit value and which clang 18 rejects under -Werror, with EQ(s.q[0].used_idx, (uint16_t)70000u) (= 4464).
The type is really 16-bit.simq declares uint16_t last_avail, used_idx; (L116).
The counter really runs 70000 times. The test_datapath loop (for (unsigned i = 0; i < 70000; i++)) calls sim_rx once per frame. sim_rx calls push_used (L216-225), which does q->used_idx++ once per RX completion. The count starts from 0 after reset (L179), and the loop requires bad == 0, so each iteration does exactly one completion. A counter that did not wrap or was wider would read 70000 and fail this check. A counter that was stuck or skipped steps would also fail. The old check could never fail.
EQ makes the test fail.EQ(a,b) is CHECK((long long)(a) == (long long)(b)), which counts the miss in failures. main then returns 1 if failures is non-zero (L618), so the test exits non-zero. It does not abort right away, but the test run fails. The (uint16_t) cast makes the expected value 4464 even after the widening to long long.
Every other changed file is a regenerated .crumb (.crumb, native/.crumb, native/net/.crumb, native/net/tests/.crumb). The only fields that change are digest, last_commit, children_root, compiled_at, generated_at_commit and source_tree. There is no hand-written logic in them.
CI at 0d73933a: CodeQL, Analyze (rust, c-cpp, actions, python), AIEN Checks and sbom all pass. AIEN Alpha was skipped.
The one blocker is the conflict with main, most likely in the regenerated .crumb files since main has moved on. After the refresh, please re-run CI. I am not approving this; that call stays with the maintainer.
— Grokbot
Fetch it
A git bundle of the pull request's head, 4930 bytes.