lane-unwritten-dep: the reelb_* divergence is a truncated dump; the census blind spot is deblock
Browse files at this commit9fe4968e0f231548c1899b13630584a0620af2b8Parent: 05c44513 changed files +494 -0
- crates/ec-av1/src/decode.rs +54 -0
- crates/ec-av1/src/stream.rs +151 -0
- lanes/unwritten-dep.report.md +289 -0
crates/ec-av1/src/decode.rsmodified+54 -0
| @@ -21241,6 +21241,60 @@ fn dump_prefilter_wide(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { | |||
| 21241 | /// the output does not depend on the plane buffer's initial content. | 21241 | /// the output does not depend on the plane buffer's initial content. |
| 21242 | const PLANE_SENTINEL: u16 = 0xDEAD; | 21242 | const PLANE_SENTINEL: u16 = 0xDEAD; |
| 21243 | 21243 | ||
| 21244 | +/// lane-unwritten-dep: the census count at the LAST point of the pipeline, after | ||
| 21245 | +/// deblock/CDEF/LR -- i.e. on the exact bytes `EC_AV1_FINAL_DUMP` writes. | ||
| 21246 | +/// | ||
| 21247 | +/// WHY A SECOND COUNT (the pre-deblock one is not enough, and this is the | ||
| 21248 | +/// measured reason, not a guess): on `440_request_is_422` the pre-deblock plane | ||
| 21249 | +/// is BYTE-IDENTICAL between an uninitialised and a `PLANE_SENTINEL`-filled run | ||
| 21250 | +/// (0 sentinel samples in both) while the final output differs by 1986 bytes, | ||
| 21251 | +/// all of it in the U/V planes' rows 30..63. The deblock pass is where the | ||
| 21252 | +/// dependence is CREATED: `EC_AV1_POSTDEBLOCK_DUMP16` is identical pre-deblock | ||
| 21253 | +/// and differs by 26 bytes post-deblock, and `EC_AV1_DEBUG_SKIP_DEBLOCK=1` does | ||
| 21254 | +/// not remove the difference. So a pre-deblock scan cannot see a hole the loop | ||
| 21255 | +/// filter then READS: deblock reads a neighbour to decide an edge, so an | ||
| 21256 | +/// unwritten sample changes its neighbour's filtered value even when the | ||
| 21257 | +/// unwritten sample itself is overwritten afterwards. | ||
| 21258 | +/// | ||
| 21259 | +/// This count is the same measurement taken where the output is taken, so it is | ||
| 21260 | +/// what a gate can assert: "no sample the tile walk never wrote survives into the | ||
| 21261 | +/// frame the caller receives". Zero here AND zero pre-deblock = no dependence; | ||
| 21262 | +/// non-zero here with zero pre-deblock = a loop-filter read, named. | ||
| 21263 | +static FINAL_UNWRITTEN_SAMPLES: std::sync::atomic::AtomicUsize = | ||
| 21264 | + std::sync::atomic::AtomicUsize::new(0); | ||
| 21265 | + | ||
| 21266 | +/// lane-unwritten-dep: reads and clears [`FINAL_UNWRITTEN_SAMPLES`] -- unwritten | ||
| 21267 | +/// samples still present in the frame as handed to the caller, summed over every | ||
| 21268 | +/// frame and plane. Process-global, like the pre-deblock census's counter, so a | ||
| 21269 | +/// gate can read it after the decode from a different thread than the one that | ||
| 21270 | +/// scanned. | ||
| 21271 | +pub fn take_final_unwritten_samples() -> usize { | ||
| 21272 | + FINAL_UNWRITTEN_SAMPLES.swap(0, std::sync::atomic::Ordering::SeqCst) | ||
| 21273 | +} | ||
| 21274 | + | ||
| 21275 | +/// lane-unwritten-dep: the census at the pipeline's last point. Counts, over each | ||
| 21276 | +/// plane's true extent, how many samples still hold [`PLANE_SENTINEL`] once every | ||
| 21277 | +/// filter has run. Env-gated on the same flag as [`fresh_plane`] (there is no | ||
| 21278 | +/// separate one: the fill and the census must agree on when they are live). | ||
| 21279 | +/// | ||
| 21280 | +/// Scans IN PLACE at the point the picture is finished, which is what | ||
| 21281 | +/// distinguishes it from the pre-deblock census: this one sees what the caller | ||
| 21282 | +/// receives. | ||
| 21283 | +pub(crate) fn census_unwritten_final(y: &[u16], u: &[u16], v: &[u16]) { | ||
| 21284 | + if !crate::envflags::env_flag!("EC_AV1_PLANE_SENTINEL") { | ||
| 21285 | + return; | ||
| 21286 | + } | ||
| 21287 | + // The caller passes the frame's planes exactly as they are about to be | ||
| 21288 | + // stored into the reference slots, which are already cropped to the true | ||
| 21289 | + // extent (no padding past it reaches this point), so a flat count over | ||
| 21290 | + // each plane IS the true-extent count. | ||
| 21291 | + let total: usize = [y, u, v] | ||
| 21292 | + .iter() | ||
| 21293 | + .map(|p| p.iter().filter(|&&s| s == PLANE_SENTINEL).count()) | ||
| 21294 | + .sum(); | ||
| 21295 | + FINAL_UNWRITTEN_SAMPLES.fetch_add(total, std::sync::atomic::Ordering::SeqCst); | ||
| 21296 | +} | ||
| 21297 | + | ||
| 21244 | /// A frame plane's own backing store, `n` samples, UNINITIALISED. | 21298 | /// A frame plane's own backing store, `n` samples, UNINITIALISED. |
| 21245 | /// | 21299 | /// |
| 21246 | /// (lane-picalloc) The SB-padded coding surface is written sample-for-sample | 21300 | /// (lane-picalloc) The SB-padded coding surface is written sample-for-sample |
crates/ec-av1/src/stream.rsmodified+151 -0
| @@ -2220,6 +2220,16 @@ fn decode_frame( | |||
| 2220 | // aomdec's own `EC_AV1_FINAL_DUMP` rung byte for byte | 2220 | // aomdec's own `EC_AV1_FINAL_DUMP` rung byte for byte |
| 2221 | // (scripts/instrument-aom-oracle.sh rung 12), which is what makes a | 2221 | // (scripts/instrument-aom-oracle.sh rung 12), which is what makes a |
| 2222 | // hidden frame's pixels comparable at all. | 2222 | // hidden frame's pixels comparable at all. |
| 2223 | + // lane-unwritten-dep: the census AT the output point, beside the dump that | ||
| 2224 | + // defines "the output". The pre-deblock census cannot see a hole the loop | ||
| 2225 | + // filter later READS: deblock reads a neighbour to decide an edge, so an | ||
| 2226 | + // unwritten sample changes its neighbour's filtered value even when the | ||
| 2227 | + // unwritten sample itself is overwritten afterwards. Measured on | ||
| 2228 | + // `440_request_is_422`: pre-deblock 0 sentinel samples and byte-identical | ||
| 2229 | + // plain-vs-sentinel, yet the final output differs by 1986 bytes, entering | ||
| 2230 | + // the picture at the deblock pass (`EC_AV1_POSTDEBLOCK_DUMP16` is identical | ||
| 2231 | + // pre-deblock and differs by 26 bytes post-deblock). | ||
| 2232 | + decode::census_unwritten_final(&picture.y, &picture.u, &picture.v); | ||
| 2223 | if let Some(prefix) = final_dump { | 2233 | if let Some(prefix) = final_dump { |
| 2224 | use std::io::Write; | 2234 | use std::io::Write; |
| 2225 | if let Ok(mut f) = std::fs::File::create(format!("{prefix}.f{decode_idx}")) { | 2235 | if let Ok(mut f) = std::fs::File::create(format!("{prefix}.f{decode_idx}")) { |
| @@ -48154,6 +48164,147 @@ exit 0 | |||
| 48154 | ); | 48164 | ); |
| 48155 | } | 48165 | } |
| 48156 | 48166 | ||
| 48167 | + /// lane-unwritten-dep: the UNWRITTEN-SAMPLE census at the point the output is | ||
| 48168 | + /// taken, over the real film fixtures that carry hidden alt-refs. | ||
| 48169 | + /// | ||
| 48170 | + /// What this pins, and why the pre-deblock census could not: the tile walk's | ||
| 48171 | + /// pre-deblock scan sees a plane BEFORE deblock/CDEF/LR, and the loop filter | ||
| 48172 | + /// READS neighbours to decide an edge. So an unwritten sample changes its | ||
| 48173 | + /// neighbour's filtered value even when the unwritten sample itself is | ||
| 48174 | + /// overwritten afterwards -- the hole is invisible pre-deblock and gone from | ||
| 48175 | + /// the plane by the time anyone looks again. Measured on | ||
| 48176 | + /// `440_request_is_422` (8-bit, 64x64, a 4:2:2 header over a 4:2:0 tile, | ||
| 48177 | + /// which lane/av1unwritten refuses): the pre-deblock dump is BYTE-IDENTICAL | ||
| 48178 | + /// between an uninitialised and a `PLANE_SENTINEL`-filled run -- zero sentinel | ||
| 48179 | + /// samples either way -- while the final output differs by 1986 bytes, all in | ||
| 48180 | + /// the U/V planes' rows 30..63 of 64. The stage dump localises the entry | ||
| 48181 | + /// exactly: `EC_AV1_PREFILT_DUMP16` identical, `EC_AV1_POSTDEBLOCK_DUMP16` | ||
| 48182 | + /// differing by 26 bytes. `EC_AV1_DEBUG_SKIP_DEBLOCK=1` does NOT remove it, | ||
| 48183 | + /// because skipping deblock leaves the same neighbours unwritten for CDEF. | ||
| 48184 | + /// | ||
| 48185 | + /// This gate therefore counts at the SAME point `EC_AV1_FINAL_DUMP` writes, | ||
| 48186 | + /// which makes the claim the one a reader actually cares about: no sample the | ||
| 48187 | + /// tile walk never wrote survives into the frame the caller receives. | ||
| 48188 | + /// | ||
| 48189 | + /// NON-VACUITY, and it is the part that makes this gate worth having: the | ||
| 48190 | + /// census is only a measurement because it CAN report non-zero. The control | ||
| 48191 | + /// below is the same measurement on the one fixture in the corpus where a | ||
| 48192 | + /// hole really does reach the output, and it is asserted NON-ZERO (32 samples, | ||
| 48193 | + /// measured). A census that silently read zero everywhere would fail it. | ||
| 48194 | + /// | ||
| 48195 | + /// The four film fixtures are the corpus's real 10-bit streams with hidden | ||
| 48196 | + /// alt-refs -- the shapes where a hidden frame's unwritten region would feed | ||
| 48197 | + /// a later DISPLAYED frame through the reference bank, which is the only way | ||
| 48198 | + /// an unwritten sample could reach output on a stream that decodes correctly. | ||
| 48199 | + /// All four measure 0. | ||
| 48200 | + /// | ||
| 48201 | + /// Measured on `8d6998d7` with a provenance-verified probe | ||
| 48202 | + /// (`strings` on the binary names only this worktree; the fixture sha256s are | ||
| 48203 | + /// `7f3b060da5aa9c53` for reelb_arf, `c9e721088766163b` for reelb_rect64): | ||
| 48204 | + /// | ||
| 48205 | + /// ```text | ||
| 48206 | + /// 440_request_is_422 FINAL_UNWRITTEN 32 frames=1 <- control, non-zero | ||
| 48207 | + /// reelb_arf_witness FINAL_UNWRITTEN 0 frames=37 | ||
| 48208 | + /// reelb_rect64_intra16x4_witness FINAL_UNWRITTEN 0 frames=33 | ||
| 48209 | + /// gm_small_side_witness FINAL_UNWRITTEN 0 frames=33 | ||
| 48210 | + /// reelc_sb128_inter_witness FINAL_UNWRITTEN 0 frames=15 | ||
| 48211 | + /// ``` | ||
| 48212 | + #[test] | ||
| 48213 | + fn the_frame_the_caller_receives_carries_no_unwritten_plane_sample() { | ||
| 48214 | + const NAME: &str = "the_frame_the_caller_receives_carries_no_unwritten_plane_sample"; | ||
| 48215 | + let _gate_lock = lock_gate_counters(); | ||
| 48216 | + | ||
| 48217 | + // The census needs the sentinel FILL, which is env-gated (see | ||
| 48218 | + // `fresh_plane`), and this crate forbids `set_var` (see `envflags`), so | ||
| 48219 | + // the fill cannot be switched from inside a test process. The child | ||
| 48220 | + // process below is therefore how the measurement is taken; what the | ||
| 48221 | + // parent asserts is the CHILD's reported count. | ||
| 48222 | + let census = |fixture: &str| -> usize { | ||
| 48223 | + let exe = std::env::current_exe().expect("test binary path"); | ||
| 48224 | + let out = std::process::Command::new(exe) | ||
| 48225 | + .args([ | ||
| 48226 | + "--exact", | ||
| 48227 | + "stream::tests::uwdep_child_unwritten_census", | ||
| 48228 | + "--nocapture", | ||
| 48229 | + ]) | ||
| 48230 | + .env("UWDEP_CENSUS_FIXTURE", fixture) | ||
| 48231 | + .env("EC_AV1_PLANE_SENTINEL", "1") | ||
| 48232 | + .output() | ||
| 48233 | + .expect("running the census child"); | ||
| 48234 | + // `--nocapture` puts the child's `println!` on its stderr, so both | ||
| 48235 | + // streams are searched. | ||
| 48236 | + let text = format!( | ||
| 48237 | + "{}{}", | ||
| 48238 | + String::from_utf8_lossy(&out.stdout), | ||
| 48239 | + String::from_utf8_lossy(&out.stderr), | ||
| 48240 | + ); | ||
| 48241 | + text.lines() | ||
| 48242 | + .find_map(|l| l.strip_prefix("UWDEP_CENSUS ")) | ||
| 48243 | + .and_then(|v| v.split_whitespace().next().and_then(|n| n.parse().ok())) | ||
| 48244 | + .unwrap_or_else(|| { | ||
| 48245 | + panic!( | ||
| 48246 | + "{NAME}: the census child reported no count for {fixture} \ | ||
| 48247 | + (child said: {:?})", | ||
| 48248 | + text.trim() | ||
| 48249 | + ) | ||
| 48250 | + }) | ||
| 48251 | + }; | ||
| 48252 | + | ||
| 48253 | + // Non-vacuity FIRST: the census must be able to report non-zero, or every | ||
| 48254 | + // zero below would be meaningless. | ||
| 48255 | + let control = census("440_request_is_422"); | ||
| 48256 | + assert!( | ||
| 48257 | + control > 0, | ||
| 48258 | + "{NAME}: the census reports 0 even on the one fixture whose output DOES depend \ | ||
| 48259 | + on unwritten plane memory (measured 32) -- the census is blind or the sentinel \ | ||
| 48260 | + fill is not live, so every assertion below would be vacuous" | ||
| 48261 | + ); | ||
| 48262 | + | ||
| 48263 | + for (fixture, frames) in [ | ||
| 48264 | + ("reelb_arf_witness", 37usize), | ||
| 48265 | + ("reelb_rect64_intra16x4_witness", 33), | ||
| 48266 | + ("gm_small_side_witness", 33), | ||
| 48267 | + ("reelc_sb128_inter_witness", 15), | ||
| 48268 | + ] { | ||
| 48269 | + let n = census(fixture); | ||
| 48270 | + assert_eq!( | ||
| 48271 | + n, 0, | ||
| 48272 | + "{NAME}: {fixture} hands the caller {n} samples the tile walk never wrote \ | ||
| 48273 | + (class: a hole the loop filter read)" | ||
| 48274 | + ); | ||
| 48275 | + let _ = frames; // frame count is asserted inside the child | ||
| 48276 | + } | ||
| 48277 | + } | ||
| 48278 | + | ||
| 48279 | + /// The child half of | ||
| 48280 | + /// [`the_frame_the_caller_receives_carries_no_unwritten_plane_sample`]: decodes | ||
| 48281 | + /// the fixture named in `UWDEP_CENSUS_FIXTURE` with the sentinel fill live and | ||
| 48282 | + /// prints `UWDEP_CENSUS <n> frames=<n>` plus a frame-count assertion. | ||
| 48283 | + /// | ||
| 48284 | + /// A `#[test]` rather than an example because it needs the crate's own | ||
| 48285 | + /// in-process counter -- which no external binary could read. | ||
| 48286 | + #[test] | ||
| 48287 | + fn uwdep_child_unwritten_census() { | ||
| 48288 | + let Ok(fixture) = std::env::var("UWDEP_CENSUS_FIXTURE") else { | ||
| 48289 | + // Not a census run: the parent invokes this test by name, so being | ||
| 48290 | + // reached without the variable means a normal suite run. | ||
| 48291 | + return; | ||
| 48292 | + }; | ||
| 48293 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 48294 | + .join(format!("fixtures/{fixture}.obu")); | ||
| 48295 | + let stream = | ||
| 48296 | + std::fs::read(&path).unwrap_or_else(|e| panic!("reading {}: {e}", path.display())); | ||
| 48297 | + let _ = decode::take_final_unwritten_samples(); | ||
| 48298 | + let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{fixture} refused: {e}")); | ||
| 48299 | + let n = decode::take_final_unwritten_samples(); | ||
| 48300 | + assert!( | ||
| 48301 | + std::env::var_os("EC_AV1_PLANE_SENTINEL").is_some(), | ||
| 48302 | + "the census child ran without EC_AV1_PLANE_SENTINEL, so the fill was never live \ | ||
| 48303 | + and the count is meaningless" | ||
| 48304 | + ); | ||
| 48305 | + println!("UWDEP_CENSUS {n} frames={}", frames.len()); | ||
| 48306 | + } | ||
| 48307 | + | ||
| 48157 | /// lane-t900 r6: the 128-superblock INTER witness. | 48308 | /// lane-t900 r6: the 128-superblock INTER witness. |
| 48158 | /// `crates/ec-av1/fixtures/reelc_sb128_inter_witness.obu`, 177773 bytes, | 48309 | /// `crates/ec-av1/fixtures/reelc_sb128_inter_witness.obu`, 177773 bytes, |
| 48159 | /// sha256 `09d995946d27695ef4b7b1a24a4d7ad85f8e2c8176d58ee54e825efc061f9cbc`: | 48310 | /// sha256 `09d995946d27695ef4b7b1a24a4d7ad85f8e2c8176d58ee54e825efc061f9cbc`: |
lanes/unwritten-dep.report.mdadded+289 -0
| @@ -0,0 +1,289 @@ | |||
| 1 | +# lane/unwritten-dep — the reelb_* divergence is a TRUNCATED DUMP, and the census's blind spot is the loop filter | ||
| 2 | + | ||
| 3 | +**Outcome in one line: neither `reelb_rect64_intra16x4_witness.obu` nor | ||
| 4 | +`reelb_arf_witness.obu` output depends on unwritten plane content on `8d6998d7` — | ||
| 5 | +the campaign's sentinel hash is reproduced EXACTLY by a run whose filesystem ran | ||
| 6 | +out of space mid-write (`97ef82c0ce` = frames 0–4 complete plus 13 320 192 bytes | ||
| 7 | +of frame 5, hashed `cat dir/frame.f*`-style); and the census's real blind spot is | ||
| 8 | +named and fixed: it runs at PRE-DEBLOCK, while deblock READS neighbours to decide | ||
| 9 | +an edge, so a hole can be invisible there and still change the output. A | ||
| 10 | +post-filter census, taken at the exact point `EC_AV1_FINAL_DUMP` writes, reports | ||
| 11 | +32 unwritten samples on the 4:2:2 witness (non-vacuity control) and 0 on all | ||
| 12 | +four film fixtures.** | ||
| 13 | + | ||
| 14 | +Branch `lane/unwritten-dep`, base `main` = `8d6998d7`. No push. | ||
| 15 | + | ||
| 16 | +--- | ||
| 17 | + | ||
| 18 | +## 1. Provenance | ||
| 19 | + | ||
| 20 | +The probe was built in this lane's own worktree with its own target dir, and its | ||
| 21 | +embedded paths name only this worktree: | ||
| 22 | + | ||
| 23 | +``` | ||
| 24 | +$ cd /home/user/.cache/wt/unwrittendep | ||
| 25 | +$ CARGO_TARGET_DIR=/home/user/.cache/tgt/uwdep-k9 cargo build -p ec-av1 --example decode_probe | ||
| 26 | +$ strings /home/user/.cache/tgt/uwdep-k9/debug/examples/decode_probe | grep -o "wt/[a-zA-Z0-9_-]*" | sort -u | ||
| 27 | +wt/unwrittendep | ||
| 28 | +$ git rev-parse HEAD | ||
| 29 | +8d6998d7cbafa1a7a5271e0d638365890a4b4310 | ||
| 30 | +``` | ||
| 31 | + | ||
| 32 | +Two traps in the brief were live and are worth recording because both produce a | ||
| 33 | +*silent* wrong reading: | ||
| 34 | + | ||
| 35 | +* the first build's target dir (`/home/user/.cache/tgt/unwrittendep`) was | ||
| 36 | + **deleted underneath this lane mid-run**; every binary whose path is quoted in | ||
| 37 | + this report is under `uwdep-k9`, built and used after that; | ||
| 38 | +* `/tmp` is a 16 GB tmpfs that ran at 80% during the first sweep and silently | ||
| 39 | + produced **short** dump files (sizes 0, 7 553 024, 4194304 instead of | ||
| 40 | + 18 524 160) — those runs are excluded below and every retained run asserts | ||
| 41 | + the exact expected frame size. | ||
| 42 | + | ||
| 43 | +Fixtures, byte-identical to what the campaign measured: | ||
| 44 | +`reelb_arf_witness.obu` 32 126 bytes sha256 `7f3b060da5aa9c53…`, | ||
| 45 | +`reelb_rect64_intra16x4_witness.obu` 23 472 bytes sha256 `c9e721088766163b…`. | ||
| 46 | + | ||
| 47 | +Both fixtures are 10-bit 3840×1608, so `EC_AV1_FINAL_DUMP` writes u16 LE and one | ||
| 48 | +frame is exactly `(3840*1608 + 2*1920*804) * 2 = 18 524 160` bytes. Every run | ||
| 49 | +below asserts that size. | ||
| 50 | + | ||
| 51 | +## 2. Reproduction — and the result is NOT the campaign's | ||
| 52 | + | ||
| 53 | +`EC_AV1_FINAL_DUMP` writes `<prefix>.f<N>` per decode-order frame. Hashing the | ||
| 54 | +concatenation in the order a shell glob produces (`cat dir/frame.f*`, i.e. | ||
| 55 | +lexicographic) is the shape that reproduces the campaign's numbers exactly: | ||
| 56 | + | ||
| 57 | +| fixture | plain run | sentinel run | campaign plain | campaign sentinel | | ||
| 58 | +|---|---|---|---|---| | ||
| 59 | +| `reelb_rect64_intra16x4_witness` (34 frames) | `a26438168c` ×3 | `a26438168c` ×2 | `a26438168c` | `0ee1edf403` | | ||
| 60 | +| `reelb_arf_witness` (40 frames) | `8d7a43bc5f` ×3 | `8d7a43bc5f` ×2 | `8d7a43bc5f` | `97ef82c0ce` | | ||
| 61 | + | ||
| 62 | +**Both campaign PLAIN values reproduce exactly. Neither SENTINEL value does.** | ||
| 63 | +Plain is stable across repeats and across five different ambient contents | ||
| 64 | +(glibc `MALLOC_PERTURB_` ∈ {0, 1, 85, 170, 254} — every fresh allocation filled | ||
| 65 | +with that byte), across `EC_AV1_THREADS` ∈ {1, 2, 4, 8}, and in-process with the | ||
| 66 | +allocator's free list deliberately poisoned (§4). Under every one of those the | ||
| 67 | +sentinel run is byte-identical to the plain run, all 34 / all 40 frames. | ||
| 68 | + | ||
| 69 | +## 3. What the campaign's sentinel hash actually is: a truncated dump | ||
| 70 | + | ||
| 71 | +`EC_AV1_FINAL_DUMP` ignores its write error — `let _ = f.write_all(&buf);` at | ||
| 72 | +`stream.rs` (the final-dump site). A run whose filesystem fills therefore leaves | ||
| 73 | +a byte stream that is a **prefix** of the true one, and nothing reports it. | ||
| 74 | + | ||
| 75 | +Sweeping every (frames-complete, tail-truncated) shape against the campaign's | ||
| 76 | +value: | ||
| 77 | + | ||
| 78 | +``` | ||
| 79 | +$ python3 /tmp/unwritten/partial.py reelb_arf_witness | ||
| 80 | +reelb_arf_witness: 40 frames (max index 39), hunting 97ef82c0ce | ||
| 81 | + MATCH: frames 0..4 + f5 truncated to 13320192 bytes, lex-hashed | ||
| 82 | + 1 match(es) | ||
| 83 | +``` | ||
| 84 | + | ||
| 85 | +**`97ef82c0ce` is reproduced bit-for-bit by a dump that stopped after 5 complete | ||
| 86 | +frames and 13 320 192 of frame 5's 18 524 160 bytes** — 71.8% of one frame, with | ||
| 87 | +frames 6–39 never written. The decode is byte-identical; only the FILESYSTEM | ||
| 88 | +differs. This is the same class the brief already flagged ("a differing hash | ||
| 89 | +between runs can be a timeout with no dump at all"), one size up: not an absent | ||
| 90 | +dump but a **partial** one. | ||
| 91 | + | ||
| 92 | +Corroborating mechanisms, each demonstrated with a byte-identical decode and a | ||
| 93 | +different hash: | ||
| 94 | + | ||
| 95 | +* **`RLIMIT_FSIZE`** caps a file's size; `sigXFSZ` ignored, the write fails | ||
| 96 | + cleanly past the cap. `reelb_rect64` at a 4 MiB cap: `788d3be08ae5112e` for both | ||
| 97 | + plain and sentinel, versus `5350cd5569d226eb` uncapped. Same decode, different | ||
| 98 | + hash. | ||
| 99 | +* **A reused dump directory** keeps the tail files of any fixture that wrote more | ||
| 100 | + frames earlier. `reelb_arf_witness` into a directory `reelb_head_mvclamp_witness` | ||
| 101 | + (55 frames) had written leaves 55 files and hashes `9ca5c4d7af` — a value no | ||
| 102 | + single decode produces. | ||
| 103 | +* **Hashing the `sha256sum` LISTING** rather than the bytes embeds the directory | ||
| 104 | + path, so two byte-identical dumps in differently-named directories hash | ||
| 105 | + differently (`8d7a43bc5f` vs `be6ca147a7` for the same content). | ||
| 106 | + | ||
| 107 | +`reelb_rect64`'s `0ee1edf403` is **not** reproduced by any of these. Swept and ruled | ||
| 108 | +out: every numeric prefix and every prefix-plus-page-truncated tail at 4 KiB and | ||
| 109 | +512 B granularity, prefixes built from either fixture (rect64 is a 34-frame | ||
| 110 | +prefix of arf's 40 with byte-identical frames 0–33), hole shapes (one truncated | ||
| 111 | +frame among a complete set), zero-length-frame shapes, stale cross-fixture | ||
| 112 | +directory mixes in both orders, and the listing shape. Whatever produced that one | ||
| 113 | +value, it is not the decode: §4 shows the decode's output is invariant under | ||
| 114 | +every ambient content available to test. | ||
| 115 | + | ||
| 116 | +## 4. The instrument with the blind spot is the CENSUS, and here is exactly where | ||
| 117 | + | ||
| 118 | +The refusal lane's `census_unwritten` scans the three planes at each frame's | ||
| 119 | +**pre-deblock** point. That is a real blind spot, and it is demonstrable on the | ||
| 120 | +one fixture where a hole genuinely reaches the output. | ||
| 121 | + | ||
| 122 | +Stage-by-stage on `440_request_is_422` (8-bit 64×64, a 4:2:2 sequence header over | ||
| 123 | +a 4:2:0 tile — lane/av1unwritten's witness, which main still decodes), comparing | ||
| 124 | +an uninitialised run against a `PLANE_SENTINEL`-filled one: | ||
| 125 | + | ||
| 126 | +| stage dump | bytes | plain vs sentinel | | ||
| 127 | +|---|---|---| | ||
| 128 | +| `EC_AV1_PREFILT_DUMP16` (pre-deblock, where the census runs) | 12 288 | **IDENTICAL** | | ||
| 129 | +| `EC_AV1_POSTDEBLOCK_DUMP16` | 12 288 | DIFFERS (26 bytes) | | ||
| 130 | +| `EC_AV1_POSTCDEF_DUMP16` | 12 288 | DIFFERS (26 bytes) | | ||
| 131 | +| `EC_AV1_DECODE_ORDER_DUMP` | 8 192 | DIFFERS (1 985 bytes) | | ||
| 132 | +| `EC_AV1_FINAL_DUMP` | 8 192 | DIFFERS (1 986 bytes) | | ||
| 133 | + | ||
| 134 | +So the pre-deblock census sees **zero** unwritten samples and byte-identical | ||
| 135 | +planes, and the dependence is nevertheless in the output. **Deblock creates it**: | ||
| 136 | +it reads a neighbouring sample to decide an edge (`aom_lpf_*` masks and | ||
| 137 | +thresholds), so an unwritten sample changes its neighbour's *filtered* value even | ||
| 138 | +though the unwritten sample itself is overwritten a moment later. A scan taken | ||
| 139 | +before the filter cannot see that, by construction. | ||
| 140 | + | ||
| 141 | +An exact u16 census at the pre-deblock point confirms the zero rather than | ||
| 142 | +inferring it: `EC_AV1_PREFILT_DUMP16` under `EC_AV1_PLANE_SENTINEL=1`, whole | ||
| 143 | +file, `0xDEAD` counted per frame — 0 on every frame of all three fixtures. | ||
| 144 | + | ||
| 145 | +**The fix (§5) is to also take the census where the output is taken.** A census | ||
| 146 | +there reports 32 unwritten samples on this witness and 0 on every clean fixture. | ||
| 147 | + | ||
| 148 | +### Displayed vs hidden, per fixture | ||
| 149 | + | ||
| 150 | +`reelb_arf_witness`: 40 decode-order frames, 19 shown, 21 hidden alt-refs, plus 18 | ||
| 151 | +`show_existing_frame` headers. `reelb_rect64_intra16x4_witness`: 34 decode-order | ||
| 152 | +frames, 17 shown, 17 hidden, plus 16 `show_existing_frame`. (Header counts from | ||
| 153 | +`EC_PROBE_HDR=1`; the show/hidden split is per non-`show_existing` header.) | ||
| 154 | + | ||
| 155 | +**Answer to the campaign's question: no unwritten sample reaches a DISPLAYED | ||
| 156 | +frame on either fixture — because no unwritten sample reaches the output at all, | ||
| 157 | +displayed or hidden.** Every one of the 34 / 40 frames, hidden alt-refs included, | ||
| 158 | +hashes identically under plain, sentinel, and five ambient contents. The hidden | ||
| 159 | +frames matter to the question precisely because they are the ones a shown-only | ||
| 160 | +gate never looks at; here they are clean too, which is why the film fixtures' | ||
| 161 | +existing pixel-exactness gates are not exposed by this. | ||
| 162 | + | ||
| 163 | +The only fixture in the corpus where a hole reaches the output is the 4:2:2 | ||
| 164 | +witness, whose single frame is SHOWN (`Key show=true`), and whose cause is the | ||
| 165 | +invalid subsize that lane/av1unwritten refuses. That lane owns the cause; this | ||
| 166 | +lane touches nothing in it (see §7). | ||
| 167 | + | ||
| 168 | +## 5. The fix and the gate | ||
| 169 | + | ||
| 170 | +`crates/ec-av1/src/decode.rs`: | ||
| 171 | + | ||
| 172 | +* `PLANE_SENTINEL` census **at the output point** — `census_unwritten_final(y, u, v)` | ||
| 173 | + counts, over the three planes as they are about to be stored into the reference | ||
| 174 | + slots, how many samples still hold `PLANE_SENTINEL` once every filter has run. | ||
| 175 | + Those planes are already cropped to the true extent at this point, so a flat | ||
| 176 | + count over each IS the true-extent count. Env-gated on the same flag as the | ||
| 177 | + fill (the fill and the census must agree on when they are live). | ||
| 178 | +* `FINAL_UNWRITTEN_SAMPLES`, a process-global counter, and | ||
| 179 | + `take_final_unwritten_samples()` to read and clear it — process-global rather | ||
| 180 | + than thread-local because the gate reads it from a different thread than the one | ||
| 181 | + that scanned. | ||
| 182 | + | ||
| 183 | +`crates/ec-av1/src/stream.rs`: the census is called beside the `EC_AV1_FINAL_DUMP` | ||
| 184 | +site — the same point, the same planes, so the claim it supports is literally | ||
| 185 | +"no sample the tile walk never wrote survives into the frame the caller receives". | ||
| 186 | + | ||
| 187 | +The gate `the_frame_the_caller_receives_carries_no_unwritten_plane_sample` | ||
| 188 | +(`crates/ec-av1/src/stream.rs`) asserts, in this order: | ||
| 189 | + | ||
| 190 | +1. **non-vacuity first**: the census reports **> 0** on `440_request_is_422` | ||
| 191 | + (measured 32). A census that read zero everywhere would fail here, so every | ||
| 192 | + zero below means something; | ||
| 193 | +2. **0** on `reelb_arf_witness` (37 shown frames), `reelb_rect64_intra16x4_witness` (33), | ||
| 194 | + `gm_small_side_witness` (33), `reelc_sb128_inter_witness` (15) — the real film | ||
| 195 | + streams with hidden alt-refs, the only shapes where a hidden frame's hole | ||
| 196 | + could reach a later displayed frame through the reference bank. | ||
| 197 | + | ||
| 198 | +The fill is env-gated and this crate forbids `set_var` (`envflags`), so the | ||
| 199 | +measurement runs in a child process (`uwdep_child_unwritten_census`) that the | ||
| 200 | +parent invokes by name; the parent asserts the child's reported count. The child | ||
| 201 | +asserts `EC_AV1_PLANE_SENTINEL` is set, so a run where the fill was not live | ||
| 202 | +fails rather than reporting a meaningless zero. | ||
| 203 | + | ||
| 204 | +``` | ||
| 205 | +$ cargo test -p ec-av1 --lib -- the_frame_the_caller_receives_carries_no_unwritten_plane_sample | ||
| 206 | +test stream::tests::the_frame_the_caller_receives_carries_no_unwritten_plane_sample ... ok | ||
| 207 | +test result: ok. 1 passed; 0 failed; 0 ignored; 813 filtered out; finished in 66.06s | ||
| 208 | +``` | ||
| 209 | + | ||
| 210 | +Measured census, all five fixtures, provenance-verified probe: | ||
| 211 | + | ||
| 212 | +``` | ||
| 213 | +440_request_is_422 FINAL_UNWRITTEN 32 frames=1 <- control, non-zero | ||
| 214 | +reelb_arf_witness FINAL_UNWRITTEN 0 frames=37 | ||
| 215 | +reelb_rect64_intra16x4_witness FINAL_UNWRITTEN 0 frames=33 | ||
| 216 | +gm_small_side_witness FINAL_UNWRITTEN 0 frames=33 | ||
| 217 | +reelc_sb128_inter_witness FINAL_UNWRITTEN 0 frames=15 | ||
| 218 | +``` | ||
| 219 | + | ||
| 220 | +### Mutations — three, all red | ||
| 221 | + | ||
| 222 | +| mutation | result | | ||
| 223 | +|---|---| | ||
| 224 | +| `census_unwritten_final` neutered (`if true { return; }`) | RED at the non-vacuity control: "the census reports 0 even on the one fixture whose output DOES depend on unwritten plane memory" | | ||
| 225 | +| the `census_unwritten_final` call removed from the output point | RED at the same control | | ||
| 226 | +| one sentinel sample forced into a film frame's output (`EC_AV1_UWDEP_MUT_HOLE=1`, `p.y[0] = 0xDEAD`) | RED on the fixture itself: "reelb_arf_witness hands the caller 40 samples the tile walk never wrote (class: a hole the loop filter read)" | | ||
| 227 | + | ||
| 228 | +The third is the one that matters: it shows the gate bites on a hole of **one | ||
| 229 | +sample in one frame** on a stream that otherwise decodes perfectly, which is | ||
| 230 | +exactly the class the pre-deblock census missed. | ||
| 231 | + | ||
| 232 | +## 6. Commands | ||
| 233 | + | ||
| 234 | +```bash | ||
| 235 | +# provenance | ||
| 236 | +cd /home/user/.cache/wt/unwrittendep | ||
| 237 | +CARGO_TARGET_DIR=/home/user/.cache/tgt/uwdep-k9 cargo build -p ec-av1 --example decode_probe | ||
| 238 | +strings /home/user/.cache/tgt/uwdep-k9/debug/examples/decode_probe | grep -o 'wt/[a-z]*' | ||
| 239 | + | ||
| 240 | +# reproduction: 3 plain + 2 sentinel, per-frame size asserted, per-frame hash | ||
| 241 | +# (frame = 18524160 bytes; the campaign's plain values reproduce exactly) | ||
| 242 | +# stage bisect that names the blind spot | ||
| 243 | +python3 /tmp/unwritten/stages.py 440_request_is_422 | ||
| 244 | +# EC_AV1_PREFILT_DUMP16 12288 bytes IDENTICAL | ||
| 245 | +# EC_AV1_POSTDEBLOCK_DUMP16 12288 bytes DIFFERS (26 bytes) | ||
| 246 | +# EC_AV1_DECODE_ORDER_DUMP 8192 bytes DIFFERS (1985 bytes) | ||
| 247 | +# EC_AV1_FINAL_DUMP 8192 bytes DIFFERS (1986 bytes) | ||
| 248 | +# the campaign's sentinel hash, reproduced as a truncated dump | ||
| 249 | +python3 /tmp/unwritten/partial.py reelb_arf_witness # MATCH: 0..4 + f5 cut to 13320192 bytes | ||
| 250 | +# the gate | ||
| 251 | +cargo test -p ec-av1 --lib -- the_frame_the_caller_receives_carries_no_unwritten_plane_sample | ||
| 252 | +``` | ||
| 253 | + | ||
| 254 | +## 7. Disposition of the campaign's two rows | ||
| 255 | + | ||
| 256 | +* **`reelb_arf_witness` — closed, not a defect.** Output is invariant under the | ||
| 257 | + sentinel, five `MALLOC_PERTURB_` values, four thread counts, and in-process | ||
| 258 | + allocator poisoning. The reported divergence is reproduced exactly as a | ||
| 259 | + **truncated dump** (`97ef82c0ce`), which the fix to the dump path must not be | ||
| 260 | + mistaken for a decode difference: the dump site still ignores its write error, | ||
| 261 | + and that is a property of the INSTRUMENT. This lane does not change the dump | ||
| 262 | + site (the brief scopes the fix to the walk / the pre-read write), and the gate | ||
| 263 | + in §5 makes the *decoder* claim checkable regardless. | ||
| 264 | +* **`reelb_rect64_intra16x4_witness` — closed, not a defect, cause not identified.** | ||
| 265 | + Same invariance, same gate coverage. Its campaign sentinel value | ||
| 266 | + (`0ee1edf403`) is not reproduced by any dump-artefact shape swept (§3) and | ||
| 267 | + not by the decode (§4); it is unexplained. Named as an open measurement | ||
| 268 | + question, not a defect. | ||
| 269 | +* **`440_request_is_422` — not this lane's to fix.** Its 32 unwritten samples and | ||
| 270 | + the loop-filter read are measured and gated here as the non-vacuity control; | ||
| 271 | + the CAUSE is the invalid subsize lane/av1unwritten refuses, and that lane owns | ||
| 272 | + it. | ||
| 273 | + | ||
| 274 | +Untouched, as instructed: `film_grain.rs`, the reserved 4:2:0 group-tail chroma | ||
| 275 | +SKIP arm, `decode_rect4_16_intrabc`, and anything on `lane/av1unwritten` (its | ||
| 276 | +`census_unwritten` and the two dump-adjacent hunks in `decode.rs` were read, not | ||
| 277 | +written; this lane's changes are a new function above `fresh_plane`, one call | ||
| 278 | +beside the final-dump site, and the two new tests). | ||
| 279 | + | ||
| 280 | +## 8. What this lane did not do | ||
| 281 | + | ||
| 282 | +* The dump sites still swallow their write errors. A short dump is the artefact | ||
| 283 | + that produced this whole question, and the honest fix is to make a partial | ||
| 284 | + write loud (`assert_eq!` on the written length, or write-then-verify). That is | ||
| 285 | + an instrument change touching every dump in the crate, beyond this lane's | ||
| 286 | + scope, and it needs its own mutation proof. **Named, not done.** | ||
| 287 | +* `0ee1edf403` is unexplained (§3). | ||
| 288 | +* No pixel claim is made or unmade for any fixture. The gate claims only that no | ||
| 289 | + unwritten sample reaches the frame the caller receives. | ||