Skip to content

fix: batch V-cache identity key drops ctime -- sanitizer(address) race pinned out (issue #74 image-dating companion) - #128

Merged
ShixiangWang merged 3 commits into
mainfrom
fix/vcache-ctime-race
Nov 24, 2026
Merged

ShixiangWang merged 3 commits into
mainfrom
fix/vcache-ctime-race

Conversation

@ShixiangWang

Copy link
Copy Markdown
Contributor

What

The 2026-11-23 scheduled deep-check (run 45200867538) reddened sanitizer(address) on hardlinked_alias_shares_the_decoding while the same-head rust arm and the local 60-run reproduction (40 under load) were green. Characterization (joint-witness file /tmp/p6gate/deepcheck-witness-20261123-evidence.txt, banked in the loop handoff REV41 addendum): a second-boundary race, not a regression — the VCache identity key {dev, ino, len, mtime(), ctime()} samples two whole-second clock stamps, POSIX link() bumps ctime, so a late alias link crossing a wall-clock second between the base stat and the alias stat yields two keys for one never-moved file: a spurious miss that violates the one-decoding-per-file law.

Why dropping ctime is the professional fix

ctime guarded no window that mtime does not already guard: any bytes move (truncate+write, pwrite) moves mtime with it, and rename-over moves dev/ino; the only events that move ctime alone are byte-less metadata events (link(), chmod) — i.e. the field produced only spurious misses on the bridge's own late-linked layout (R/kernel-bridge.R kp_serve_unit hard-links one V grid into fifty case dirs after earlier cases may already have decoded). The test-file law 4 always read "length or mtime moved" — the key field was unclaimed implementation drift.

Deterministic probe (TDD, RED witnessed first)

a_hardlink_after_a_clock_tick_still_shares_the_decoding forces the boundary instead of waiting for it: base decoded → forced second crossing (1.1 s sleep, same banked idiom as bytes_moved_under_a_name_force_a_fresh_decode) → alias linked last. Against the unfixed key: 3/3 FAILED at the ptr_eq law, right reason, timing-independent. The old flake needs a link to land in a different second; this probe makes every run that second cross. Fail-closed non-unix twin included per the file's platform discipline.

Lineage

Local attestations

  • cargo test --test batch_v_cache: 6/6 (was 1 deterministic fail)
  • cargo test full engine: 335 tests, 0 failed (kl_bit_freeze, kl_scratch_bit_exact, bridge families included)
  • cargo clippy --workspace -- -D warnings: clean
  • scheduled.yml YAML parse: OK
  • R layer untouched; no package-face change — the gate arms here are the rust arm plus the fan-out legs as confirmation.

Test plan

  • rust arm green (clippy + workspace tests + deny)
  • R CMD check fan-out legs green (kernel cdylib rebuilt from this tree; batch bridge exercises the memo)
  • guards/guards-shards/guard-prep green
  • Next scheduled deep check: sanitizer(address) leg green twice consecutive (natural fires only — no manual dispatch; second-occurrence observation per law), plus the windows cran-shape-check cancellation inspected at its next occurrence (separate forensics, unaffected by this change)

🤖 Generated with Claude Code

… a bytes move

The scheduled sanitizer(address) leg reddened 2026-11-23 (run
45200867538) on hardlinked_alias_shares_the_decoding: the VCache
identity key carries a ctime whole-second stamp, POSIX link() bumps
ctime, and when the link lands after the base stat crossed a second
the two stats disagreed on a field no bytes move ever produced --
a spurious miss on the bridge layout itself, late-linked aliases
decoding twice.

This adds the deterministic probe: base decoded, forced second crossing
(1.1 s, same idiom as the bytes-moved law), alias linked last. Three
runs against the unfixed key: 3/3 FAILED at the ptr_eq law, right
reason, timing-independent.
mtime carries the freshness law alone: any bytes move moves mtime
with it, so every window ctime guarded, mtime already guarded. The
extra field bought nothing and byte-less metadata events (link(),
chmod) bumped it, costing shared entries -- the spurious misses that
panicked the sanitizer leg. The test-file law 4 always read
"length or mtime moved": the key field was unclaimed implementation
drift, now pinned by the late-link twin in tests/batch_v_cache.rs.

GREEN: batch_v_cache 6/6 (was 1 failed deterministic), full engine
suite 335 tests 0 failed, clippy --workspace -D warnings clean.
Issue #74 image-dating ruling, same law as the valgrind arm above:
sanitizer verdicts must be observed over a still environment. The
2026-11-23 race rode ubuntu-latest while the image moved underneath
it; the defect itself is now pinned out by law, the pin keeps the
observation window still.
@ShixiangWang
ShixiangWang merged commit d668d93 into main Nov 24, 2026
9 checks passed
@ShixiangWang
ShixiangWang deleted the fix/vcache-ctime-race branch November 24, 2026 13:02
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