Registry Mirror
Skip to content

Conversation

@avrabe

@avrabe avrabe commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Two wrong-code / false-refusal fixes in synth's static-data addressing, found together.

VERWIDTH (Refs #1563)

VCR-VER-003 treated every static-data relocation as a possibly-8-byte access, so gale's meld-packed composite was refused: a 1-byte load8_u/store8 guard sits in a 1-byte segment directly before another segment, and the assumed span read the neighbour. Each relocation now carries the access width proven from the FINAL instruction stream (literal_access_width: every reader a plain [rd,#0] load/store, calls handled by the AAPCS model); unproven widths keep the conservative 8 bytes.

NPACONST (Refs #1568)

Under --native-pointer-abi (R11 = 0 by contract) many constant-address accesses were emitted as a raw offset off R11 with no relocation — a silent miscompile the validator could not see. Measured over 162 modules (19 access families x 4 address shapes x 3 module kinds) against wasmtime: 81 wrong at HEAD. Now i32 const folds relocate past 0xFFF, and every arm that cannot fold refuses loudly. Same matrix after: 0 wrong, 24 newly correct, 57 newly refused, 0 previously-correct changed.

Pins: exact emulation floor 368057 -> 368110; selector lines 19974 -> 20125 and wildcards 55 -> 56, each with a written waiver.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YJK5LZZEkV5smCY1jKn18L

t and others added 4 commits October 21, 2026 10:19
…dth from its instruction

VCR-VER-003's spanned check treated every static-data reloc as a possible
8-byte access. gale's meld-fused composite has a 1-byte load8_u/store8
constructor guard at linmem 0xe0c, in a 1-byte segment declared after the
segment at 0xe10. Span bytes +4..+7 fell in that neighbour, so the validator
refused a correct image.

WHERE THE WIDTH COMES FROM. It is derived from the shipped instruction
stream, not stated by the selector. CodeRelocation gains
`access_width: Option<u32>`. The ARM backend fills it for each LdrSym
literal word (`literal_access_width`, arm_backend.rs) by walking forward from
`LdrSym rd` until rd is killed:
- every reader must be a plain [rd, #0] LDR/LDRB/LDRSB/LDRH/LDRSH/STR/STRB/STRH
  that does not store rd itself, and the width is the max over the readers;
- BL/BLX are passed by call_effect (an argument use means None; a clobber is a
  kill); fall-through labels are passed;
- a return kills rd if the epilogue restores it or rd is R2/R3/R12;
- any other use, branch, unmodelled op, return leaving rd observable, or end of
  stream gives None.
main.rs carries the width into RelocResolution. The validator spans exactly
W bytes, strictly (an implicit-zero byte must be served as 0x00); with
None it spans 8 bytes, with the old tolerance. LdrSym is not CSE'd or shared
by any pass (grep of synth-synthesis/backend: liveness def/use, home_alias,
regalloc rename only), and the max-over-readers rule covers sharing anyway.

EXACT: const-address (eff <= 0xFFF fold) i32.load / load8_u/s / load16_u/s
and i32.store / store8 / store16.
CONSERVATIVE (8): i64 pair loads/stores (pseudo-ops, reg_effect None);
f32/f64; the dynamic-index __synth_wasm_data+offset base (Add of a register),
which also lowers const addresses above the 0xFFF fold; escaping i32.const
pointers used as [r11, rd].

RED-FIRST. A hermetic gale-shape fixture (vcr_ver_003_addr_777.rs) gives 8
span errors at HEAD (+4..+7 for the load reloc and the store reloc, "serves
0x00 but the runtime image owns 0x01", the issue's diagnostic) and compiles
clean after the fix.

CONTROLS (HEAD -> fix; correct compiler, end to end):
- staggered overlap (seg1 overwrites +2,+3 of seg0):
  - load32 @2048, load16_u/s @2049, store32 @2048, store16 @2049:
    REFUSED -> REFUSED at their exact width;
  - load8_u @2048, load8_s @2049, load8_u @2050, store8 @2049:
    REFUSED -> ACCEPTED;
- i64.load/i64.store: REFUSED -> REFUSED ("width unproven");
- cross-segment straddle (4-byte @0xe0c over A=aa bb, B=cc dd declared
  earlier): REFUSED -> REFUSED (+2 of a 4-byte access);
- dynamic index / i32.const-pointer / above-fold const @8204:
  REFUSED -> REFUSED ("width unproven");
- 4-byte load @2002 over a 4-byte segment whose packed neighbour is non-zero
  where linmem is uncovered: ACCEPTED (silent miscompile: served 05 06,
  runtime 00 00) -> REFUSED.
Unit controls (static_data_addr): the #757 first-match owner is refused at
widths 1/2/4/8/None. literal_access_width has 4 unit tests over hand-built
streams.

MUTATIONS (vcr_ver_003_addr_777, 15 tests):
- width forced to None/8: 5 red. The gale shape, narrow-access and
  implicit-zero tests flip verdict; the two refusal tests red on the wording.
- width forced to 1: 5 red, including the pre-existing #777
  span_straddling test. The binary then ACCEPTS load32, load16, store32, the
  straddle, the implicit-zero case and load64 (all rc=0).

EXECUTION. New oracle scripts/repro/verwidth_1563_differential.py
(wired in ci.yml, `emulations >= 25`). It hand-links .text/.data/.bss at
separate bases and runs the newly accepted objects against wasmtime.
- fix: 25/25 equal;
- HEAD: refused, exit 1.
Exact emulation floor re-derived on the merged tree: main 368057 -> 368082
in ci.yml and claims.yaml; oracle_wiring_check --exact-emulation-floor
368082 rc=0.

BYTE IDENTITY. 226 inputs (206 scripts/repro/*.wat, 19 scripts/repro .wasm
including mem757_gale/loom.wasm, tests/wat) x 5 configs (self-contained,
--relocatable, +--native-pointer-abi, +--shadow-stack-size 2048, -b riscv)
= 1130 compiles, HEAD vs fix:
- 641 both ok, 0 byte differences;
- 488 both refused;
- 1 verdict change: multi_segment_static_data.wat on
  --native-pointer-abi, refused -> accepted.
That module's c_head load8_u @0x200 sits before an overlap at 0x203, so the
8-byte span was a false positive. Accepting it exposes a SEPARATE, pre-existing
defect: with no stack-pointer global, const addresses above 0xFFF are baked as
an un-relocated [r11, #addr], so 5 of its 13 exports read wrong bytes. The
same shape compiles clean at HEAD whenever no other reloc trips the 8-byte
span (measured). It is filed as #1568 and fixed by RQ-88-NPACONST, the
next commit of this PR.
The litpool_islands_345 differential moves 167 -> 168 byte-identical
(34 -> 33 declines) for the same module.

ORACLES re-run HEAD vs fix, all unchanged verdicts:
static_above_sp_739, wide_static_746, wide_static_copy_757, the 7
mem757_* differentials, multi_segment_static_data, islandpass_1331,
leaf_dead_frame, multi_sp_707, native_pointer_shadow_stack,
native_pointer_static_downshift_678, call_5args, postlink_359,
litpool_islands_345(+differential).

MC/DC. validate_reloc_resolutions_spanned's branch population went 13 -> 16
(the gate's REPIN output with witness 0.42.0 / rustc 1.96.1). It was the ONLY
population that moved, and the same local run of origin/main matched every
pin. A new sd_validate_spanned_width row driver (4 rows) drives the new
branches. The report-side floors miss locally on BOTH trees (origin/main
125/46, this 127/50 vs 130/56) on darwin. Same instrument, this tree vs
origin/main: proved +4, conditions +2, dead +0. The linux CI report side is
unmeasured here. main's last MC/DC job (run 39337711432) sits exactly at
FLOOR_PROVED (56 of 56) and one under CEILING_DEAD (50 vs 51), so there is
no slack.

GALE-SHAPE VARIANTS, keeping the 0xe10 neighbour. Five compile clean with
both relocs exact:
- params used after the guard;
- a ctor taking an argument;
- more code after the call;
- no call;
- store only.
if/else around the guard stays REFUSED. The then-arm's `b` over the else
comes before the callee-saved address register is restored, so the store
width is unproven. Following an unconditional branch to its label is a
follow-up, not done here.

CHECKS: cargo fmt --check rc=0; cargo clippy --workspace --all-targets
-D warnings rc=0; cargo test --workspace rc=0 (3174 passed, 0 failed);
claim_check 75/75 rc=0; status_evidence_check rc=0; test_mcdc_gate rc=0.

Artifact: artifacts/release-v0.88/RQ-88-VERWIDTH.yaml (issue-scope: closes).

Real gale input NOT run: no gale checkout on this machine. The fixture
proves the shape, not the composite.

Refs #1563

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJK5LZZEkV5smCY1jKn18L
…-memory offset for a constant address

CONTRACT (from the source, not the harness). Under --native-pointer-abi
R11 is 0, with or without a stack-pointer global:
- CompileConfig::linear_memory_bytes: "any address beyond it is a runtime host
  pointer -> [R11=0 + addr]";
- the CLI flag doc: "linmem base = 0";
- docs/embedder-abi-relocatable-arm.md:19: "linmem base 0, statics via
  __synth_wasm_data";
- the wasm_data_base doc: "Defaults to 0 (relocate everything inside linear
  memory) for modules with no stack-pointer global";
- every existing npa oracle sets R11 = 0.
The defect does not depend on R11 either: the mixed split moves the init bytes
to .data under __synth_wasm_seg_K, so a baked [fp, #addr] reads the zero
reservation for any R11 value.

DEFECT. The selector relocated a constant static address in only three places:
(1) the i32.const handler, when a stack-pointer global marks c a pointer;
(2) the #359/#739 dynamic path, for an offset in the static region (also
stack-pointer-gated);
(3) the i32 const-address fold, which stopped at the 0xFFF imm12 limit.
Everything else was `movw rX,#addr; ldr [fp, rX]`. Execution matrix: 162
probe modules = 19 access families x 4 address shapes, in three module kinds
(no SP global; SP global at 0x80; SP global at 0x2000 with const 0x1800 +
offset 0x1000). Run against wasmtime at the pre-fix binary: 81 WRONG, 75 ok,
6 refused for unrelated reasons.

FIX. `npa_baked_const_addr` names the bake condition: npa, eff static, and
neither (1) nor (2) applies.
- try_fold_const_addr{,_store} now also fold in that case, past 0xFFF, so the
  existing LdrSym arms relocate the address.
- `npa_const_addr_guard`, a select_with_stack pre-flight, refuses it loudly on
  every arm that cannot fold: i64 loads/stores, f32/f64, v128,
  memory.fill/copy, and the i32 arms when bounds checking disables the fold.
Same matrix after: 0 WRONG; 24 previously-wrong now correct; 57
previously-wrong now refused; 0 previously-ok changed.

RESIDUE, not caught: positional rules cannot see these, and both still read
the wrong address after the fix (measured):
- a const pointer through a local
  (`i32.const 0x1004; local.set 0; local.get 0; i32.load`);
- a dynamic access with a static-region offset in a no-SP module.
Refusing every no-SP npa module would close both. 62 of the 184
repro/test inputs that compile with npa at HEAD have no stack-pointer global
and declare a memory, so that is a reach decision for the coordinator, not
taken here.

RED-FIRST. New scripts/repro/npa_const_addr_differential.py (wired,
`emulations >= 28`): no-SP shapes, multi_segment_static_data.wat, and the SP
sliver, executed against wasmtime, plus 8 refusal rows (needle,
no object, #1113 count).
- origin/main: 7 BUG on the no-SP module, then multi_seg refused (exit 1);
- VERWIDTH alone: 7 + 5 BUG, multi_seg's b_after/d_lo/d_hi/d_byte/gap
  (exit 1);
- this commit: 28/28 equal, 8/8 refused (exit 0).
New crates/synth-cli/tests/npa_const_addr_never_baked.rs: 3 tests.

MUTATIONS:
- fold extension reverted: the oracle has 12 BUG, 2 of 3 CLI tests red;
- guard call removed: the oracle reds on its first refusal row
  ("compiled with exit 0"), 2 of 3 CLI tests red.

BYTE IDENTITY, same 1130 compiles (226 inputs x 5 configs), VERWIDTH -> this:
0 diffs outside --native-pointer-abi.
- 3 npa byte changes, each a baked access now relocated:
  - add_imm_large: `movw/movt ip,#0x11170; str [fp, ip]` -> LdrSym;
  - stack_canary_687: `str [fp, r1]` at #0xf000.. -> LdrSym;
  - multi_segment_static_data: b_after/d_*/gap.
- 5 npa refusals, each function executed WRONG (faulted) at the pre-fix binary
  under R11 = 0:
  - bulk_local_clobber_677: cpy_dst/len/src/const;
  - bulk_mask_679: cpy_esc/src_esc/clamp;
  - home_alias_class_1189_promo: p_fill;
  - i64_width_vstack_mem_946: f_memcopy, f_memfill;
  - vcr_reach_001_i64_pair: ld_dead_base.
- origin/main -> this: the same set, plus multi_segment refused -> accepted.
- litpool_islands_345_differential (npa, cortex-m7 corpus): 168 -> 162
  byte-identical (floor 160). The extra m7 decline is spill_slot_alias_1321
  (f32.load at const 0x2214, the f32 family the matrix shows wrong).
- npa_ss (--shadow-stack-size) and every non-npa config: unchanged.

ORACLES re-run on this binary, all green and unchanged:
- static_above_sp_739, wide_static_746, wide_static_copy_757;
- the 7 mem757_*;
- multi_segment_static_data, islandpass_1331, leaf_dead_frame;
- multi_sp_707, native_pointer_shadow_stack, native_pointer_static_downshift_678;
- call_5args, postlink_359, litpool_islands_345 (+ differential),
  verwidth_1563.
VERWIDTH's 19 control verdicts are identical. Its two width mutations still
red 5/15 each.

PINS:
- emulation floor re-derived on the merged tree: 368082 -> 368110
  (ci.yml + claims.yaml; oracle_wiring_check rc=0);
- selector ratchets, with written waivers:
  - selector_lines_code 19974 -> 20125 (over main's JESSDIVERGE10 waiver);
  - selector_wildcard_arms_code 55 -> 56 (the guard's `_ => continue`);
  - tracked totals 30567 -> 30718 and 93 -> 94;
- artifacts/status.json regenerated.

CHECKS: cargo fmt --check rc=0; clippy --workspace --all-targets -D warnings
rc=0 (and --features verify rc=0); cargo test --workspace rc=0 (3177 passed);
claim_check 75/75 rc=0; oracle_wiring_check rc=0 (re-run on the rebased
tree before commit; see the PR for the full list).
Artifact: artifacts/release-v0.88/RQ-88-NPACONST.yaml (issue-scope: outlives,
the residue keeps #1568 open).

Refs #1568

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJK5LZZEkV5smCY1jKn18L
…ackend.rs line drift

The VERWIDTH/NPACONST edits to arm_backend.rs (literal_access_width,
105 lines above the pinned sites, plus four one-line insertions in
compile_wasm_to_arm) shifted five ci_subset sites, and the CI mutation
survey failed with "site no longer exists on this tree". Re-anchored with
the ledger's own `mutation_survey.py reanchor`: 20 sites moved, 0 not
found, no `before` text changed (pure line drift).

Paired control against enumerate_sites() on this tree: the HEAD ledger
names exactly the five ids CI reported missing; the re-anchored ledger
names none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJK5LZZEkV5smCY1jKn18L
…ion the guard leaves

CI's "Constant islands place a reachable literal pool" reded VACUOUS:
island_offset_invariant_345 declared `objects checked >= 308` and measured
307. Same 206 fixtures, 412 legs on both trees. origin/main measured 312
in CI (job 119112145324); this branch measures 307:

- six --native-pointer-abi legs are now refused by the #1568 guard, each
  for addressing a constant static-data address the old path baked as a
  raw linear-memory offset: bulk_local_clobber_677, bulk_mask_679,
  home_alias_class_1189_promo, i64_width_vstack_mem_946,
  spill_slot_alias_1321, vcr_reach_001_i64_pair (refusal text read per leg);
- one leg main refused now compiles under the per-instruction access
  width (#1563): multi_segment_static_data.

A refusal of a miscompile is the correct outcome, so the floor moves to the
measured 307, with the reason recorded beside the floor's existing
population note. Paired: the new floor exits 0 and the old 308 floor
exits 1 against the same branch binary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJK5LZZEkV5smCY1jKn18L
@avrabe
avrabe merged commit 8591492 into main Oct 21, 2026
78 of 79 checks passed
@avrabe
avrabe deleted the v088-verwidth branch October 21, 2026 19:48
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.89214% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/synth-core/src/static_data_addr.rs 94.44% 9 Missing ⚠️
crates/synth-synthesis/src/instruction_selector.rs 93.05% 5 Missing ⚠️
crates/synth-backend/src/arm_backend.rs 98.80% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant