SIGN IN SIGN UP

fix(shim): operand direction, pure kills, and an explicit bound — from the arg-count review (#89)

A corpus review over the shipped libserver.so (30,116 real function entries) returned "land it" —
1 false refusal in 3,000 correct-shape tests, 0 among 531 genuinely nullary functions, both shipping
hooks verified against their real prologues. Three findings, all fixed here.

OPERAND DIRECTION WAS BACKWARDS, and my own test hid it. 0x01/09/21/29/31 write r/m and READ reg;
the code credited `reg` as redefined, marking the SOURCE dead and leaving the real destination live.
That silently weakens every later observation (a false PASS, so it degraded detection rather than
availability). It survived because the single test covering it used `xor %edx,%edx` — the degenerate
encoding where reg == rm and direction cannot show. Split into the two ALU groups by direction, an
ALU write to MEMORY now correctly kills no register, and the decoder tests assert direction in
isolation with non-degenerate encodings so a regression names the bug instead of surfacing as a
distant false refusal.

PURE KILLS were untracked: movzx/movsx (0F B6/B7/BE/BF), cqo/cdq (99), mul/div/idiv (F7 /4,/6,/7 ->
rdx), and movq %xmm,%r64. Each fully DEFINES an argument register without reading it, so a later
spill was counted as an incoming argument and refused a correct shape. Confirmed on the real binary
at 0x22ce9f6 (movzwl -> mov %dx) and 0x12696ac — the only confirmed false-refusal source found,
~0.03%. Note the count rule had MORE exposure here than the width rule: width only fires on 64-bit
stores, and both real cases were 16-bit.

THE wide[] BOUND IS NOW EXPLICIT. `u.argIndex < count` is redundant while the count rule returns —
which is exactly why it is written out. The bound must not depend on an unrelated policy rule staying
a hard refusal: downgrading that to a warning previously walked off the caller's array
(ASan-confirmed). Relaxing it now fails the count ASSERTION with zero sanitizer hits, so memory
safety is independent of policy.

92 checks, up from 81. Three mutations driven: restoring the direction bug, dropping the movzx kill,
and relaxing the count refusal each break exactly the tests that should catch them.
G
Gabriel Hirakawa committed
3a4f587de3c8729f55348ea0a2a4455cfb6572ce
Parent: f1831b8
Committed by GitHub <noreply@github.com> on 8/4/2026, 7:33:59 AM