From 286530d7a4335ad12ea3d3679c30a91a6f08990d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 1 Oct 2026 20:58:11 +0300 Subject: [PATCH] ec-av1: every dump site fails loudly on a short write All 11 dump write sites in the crate wrote through `let _ = f.write_all(..)`. A full filesystem, a quota or an RLIMIT_FSIZE therefore left a SHORT file on disk and nothing said so -- the artefact behind two full days of chasing a "decoder nondeterminism" that reproduced bit-for-bit as a truncated frame (lanes/unwritten-dep.report.md: frames 0..4 complete plus 13320192 bytes of frame 5), and behind an empty dump read as instability. New `dumpio::LoudDump`: the caller declares the byte count from the geometry it already has (per-axis extents, u16-vs-u8 sample width), `finish()` checks it against the file's own length on disk, and any shortfall -- or a failure to create the file at all -- aborts with ec-av1 dump FAILED [EC_AV1_FINAL_DUMP] : wrote of bytes: Two sites cannot know a total length (EC_AV1_DUMP_TABLES and the ECDUMP symbol stream are append-mode, whole-run files); they say "of an unknown number of bytes" rather than declaring a number they would have to invent. The written count is the file's MEASURED length, not what write_all confirmed: under RLIMIT_FSIZE the kernel stores up to the cap and only then returns EFBIG, so a naive acknowledged count reported "wrote 0" over a 30 720-byte file. Gates: a real decode under a real RLIMIT_FSIZE now FAILS with the line above (child process, SIGXFSZ ignored, asserted against the fragment's real length), plus /dev/full, uncreatable-path, under-declared-length and append-unknown arms. The success path is byte-identical: the hg fixture sweep reproduces a26438168c / 8d7a43bc5f, 3/3 each, 18524160 B per frame. 0ee1edf403 is still NOT reproduced (plain 3/3, sentinel 3/3, concurrent reuse, 7 RLIMIT caps, 204 prefix shapes: all plain value or no match). It stays open -- a SIGKILLed process emits no line at all, so that shape is not ruled out. What is now closed is the silent-truncation class: every truncating cap aborts loudly instead of leaving an artefact. --- crates/ec-av1/src/decode.rs | 122 ++++++----- crates/ec-av1/src/dumpio.rs | 399 ++++++++++++++++++++++++++++++++++++ crates/ec-av1/src/lib.rs | 1 + crates/ec-av1/src/msac.rs | 32 ++- crates/ec-av1/src/stream.rs | 86 ++++---- lanes/av1dumploud.report.md | 284 +++++++++++++++++++++++++ 6 files changed, 833 insertions(+), 91 deletions(-) create mode 100644 crates/ec-av1/src/dumpio.rs create mode 100644 lanes/av1dumploud.report.md diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 7704d7cb..cb682f26 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -21154,7 +21154,6 @@ fn dump_stage16( ss_x: usize, ss_y: usize, ) { - use std::io::Write; // lane-sbrect10 r2 / lane-cdef r1 (one shared helper): index the dump by // decode-order picture like EC_AV1_PREFILT_DUMP already does -- a fixed // `.f0` name kept only the LAST frame, so a mid-sequence divergence could @@ -21173,25 +21172,36 @@ fn dump_stage16( // the same rounding the // decoder's own plane extents use, and it matches the oracle's // `uv_crop_width` / `uv_crop_height` per axis. + // // ONE file per frame: `dump_stage_idx` advances on every call, so creating // the file inside the plane loop would write three files per frame and // shift every later frame's index. - if let Ok(path) = crate::envflags::var(var) - && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) - { - for (p, w, h) in [ - (y, fw, fh), - (u, round_ss(fw, ss_x), round_ss(fh, ss_y)), - (v, round_ss(fw, ss_x), round_ss(fh, ss_y)), - ] { + // + // lane-av1dumploud: this used to be `let _ = f.write_all(&bytes)` per row, so + // a full filesystem left a SHORT file that no reader could tell from a + // complete one. `LoudDump` is given the exact expected length this function + // knows -- `(fw*fh + 2*cw*ch) * 2`, u16 LE -- and checks it against the file + // on disk; a shortfall aborts the decode instead of leaving a plausible + // artefact behind. + if let Ok(path) = crate::envflags::var(var) { + let cw = round_ss(fw, ss_x); + let ch = round_ss(fh, ss_y); + let expected = (fw * fh + 2 * cw * ch) * 2; + let mut d = crate::dumpio::LoudDump::create( + var, + format!("{path}.f{}", dump_stage_idx(var)), + expected, + ); + for (p, w, h) in [(y, fw, fh), (u, cw, ch), (v, cw, ch)] { for row in 0..h { let mut bytes = Vec::with_capacity(w * 2); for &s in &p.data[row * p.width..][..w] { bytes.extend_from_slice(&s.to_le_bytes()); } - let _ = f.write_all(&bytes); + d.write(&bytes); } } + d.finish(); } } @@ -21214,14 +21224,17 @@ fn dump_stage_idx(var: &str) -> usize { } fn dump_stage(var: &str, y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { - use std::io::Write; - if let Ok(path) = crate::envflags::var(var) - && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) - { - for p in [y, u, v] { - let narrow: Vec = p.data.iter().map(|&s| s as u8).collect(); - let _ = f.write_all(&narrow); - } + // lane-av1dumploud: loud on a short write (see [`crate::dumpio::LoudDump`]). + // The expected length is the three planes' own data lengths -- the writer + // iterates exactly `p.data`, so this is the same extent, not a re-derivation + // that could disagree with it. + if let Ok(path) = crate::envflags::var(var) { + let narrow = |p: &PlaneBuf<'_>| -> Vec { p.data.iter().map(|&s| s as u8).collect() }; + crate::dumpio::write_planes( + var, + format!("{path}.f{}", dump_stage_idx(var)), + &[&narrow(y), &narrow(u), &narrow(v)], + ); } } @@ -21247,7 +21260,9 @@ fn dump_prefilter_wide(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_WIDE_DUMP") else { return; }; - use std::io::Write; + // lane-av1dumploud: loud on a short write. Expected length is + // `sum(true_width * true_height)` over the three planes -- the crop the + // writer itself builds, so the check cannot disagree with the bytes. let idx = dump_stage_idx("EC_AV1_PREFILT_WIDE_DUMP"); let crop = |plane: &PlaneBuf<'_>| -> Vec { let mut out = Vec::with_capacity(plane.true_width * plane.true_height); @@ -21260,11 +21275,12 @@ fn dump_prefilter_wide(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { } out }; - if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) { - let _ = f.write_all(&crop(y)); - let _ = f.write_all(&crop(u)); - let _ = f.write_all(&crop(v)); - } + let (cy, cu, cv) = (crop(y), crop(u), crop(v)); + crate::dumpio::write_planes( + "EC_AV1_PREFILT_WIDE_DUMP", + format!("{path}.f{idx}"), + &[&cy, &cu, &cv], + ); } /// Enabled by `EC_AV1_PLANE_SENTINEL` (there is no separate flag for it): print @@ -38218,15 +38234,18 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( ); census_unwritten(&y, &u, &v); if let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_DUMP") { - use std::io::Write; + // lane-av1dumploud: loud on a short write (three discarded + // `write_all` results before). Expected length = the three planes' own + // data lengths: this dump is the PADDED plane, not a crop, so the + // writer's extent is `p.data` itself. let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); - if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) { - let narrow = - |p: &PlaneBuf<'_>| -> Vec { p.data.iter().map(|&s| s as u8).collect() }; - let _ = f.write_all(&narrow(&y)); - let _ = f.write_all(&narrow(&u)); - let _ = f.write_all(&narrow(&v)); - } + let narrow = + |p: &PlaneBuf<'_>| -> Vec { p.data.iter().map(|&s| s as u8).collect() }; + crate::dumpio::write_planes( + "EC_AV1_PREFILT_DUMP", + format!("{path}.f{idx}"), + &[&narrow(&y), &narrow(&u), &narrow(&v)], + ); } else { PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); } @@ -38449,16 +38468,22 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( *m.borrow_mut() = if true_width > fw || true_height > fh { let yc = crop(&y, true_width, true_height); if let Ok(path) = crate::envflags::var("EC_AV1_MARGIN_DUMP") { - use std::io::Write; static IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); let idx = IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); - if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) { - // corner-cut: this diagnostic dump stays 8-bit-narrowed - // regardless of the stream's real bit depth (debug-only, - // never read by a gate); widen if a >8-bit margin dump - // is ever needed. - let _ = f.write_all(&yc.iter().map(|&s| s as u8).collect::>()); - } + // corner-cut: this diagnostic dump stays 8-bit-narrowed + // regardless of the stream's real bit depth (debug-only, + // never read by a gate); widen if a >8-bit margin dump + // is ever needed. + // + // lane-av1dumploud: loud on a short write. Expected length is + // `true_width * true_height` -- the crop this dump is exactly, + // not a re-derived geometry. + let narrow: Vec = yc.iter().map(|&s| s as u8).collect(); + crate::dumpio::write_planes( + "EC_AV1_MARGIN_DUMP", + format!("{path}.f{idx}"), + &[&narrow], + ); } Some(Picture { width: true_width, @@ -56586,15 +56611,16 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( ); census_unwritten(&y, &u, &v); if let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_DUMP") { - use std::io::Write; + // lane-av1dumploud: loud on a short write (see the key-frame twin + // above -- same file, same shape, same three planes). let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); - if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) { - let narrow = - |p: &PlaneBuf<'_>| -> Vec { p.data.iter().map(|&s| s as u8).collect() }; - let _ = f.write_all(&narrow(&y)); - let _ = f.write_all(&narrow(&u)); - let _ = f.write_all(&narrow(&v)); - } + let narrow = + |p: &PlaneBuf<'_>| -> Vec { p.data.iter().map(|&s| s as u8).collect() }; + crate::dumpio::write_planes( + "EC_AV1_PREFILT_DUMP", + format!("{path}.f{idx}"), + &[&narrow(&y), &narrow(&u), &narrow(&v)], + ); } else { PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); } diff --git a/crates/ec-av1/src/dumpio.rs b/crates/ec-av1/src/dumpio.rs new file mode 100644 index 00000000..924a6c28 --- /dev/null +++ b/crates/ec-av1/src/dumpio.rs @@ -0,0 +1,399 @@ +//! Loud dump writing: a dump that cannot hold every byte it claims to hold is +//! a failure, not a diagnostic artefact. +//! +//! lane-av1dumploud: every dump site in this crate wrote through +//! `let _ = f.write_all(..)`. A full filesystem, an `RLIMIT_FSIZE`, or any other +//! `ENOSPC`/`EFBIG` therefore left a SHORT file on disk and nothing said so. +//! Measured consequence, twice in one day: a sentinel-vs-plain hash difference +//! that read as decoder nondeterminism reproduced bit-for-bit as a truncated +//! dump (`lanes/unwritten-dep.report.md`: frames 0..4 complete plus 13 320 192 +//! bytes of frame 5, with `EC_AV1_FINAL_DUMP`'s discarded write error), and an +//! empty dump read as instability. That artefact started a whole defect class, +//! and a silently wrong diagnostic is worse than a loud one, so every dump site +//! goes through [`LoudDump`]: the caller states the expected byte count from the +//! geometry it already has, the writer checks that count twice -- once against +//! the bytes it was handed, once against the file's own length on disk -- and +//! any shortfall aborts the decode with the file, the counts, and the OS error. +//! +//! The success path is byte-identical to the old `write_all` loop: same bytes, +//! same order, same file names. +//! +//! The failure path is a panic, not a returned `Result`: the dump sites sit in +//! the middle of `fn decode_*` functions with no error channel for them, and a +//! dump that failed IS a decode failure (the run's measurement is void). This +//! is a debug instrument -- it only runs when its env var is set -- so the +//! panic cannot affect a normal decode. + +use std::fs::{File, OpenOptions}; +use std::io::Write; +use std::path::{Path, PathBuf}; + +/// One dump file, with the byte count it owes accounted for as it goes. +pub struct LoudDump { + /// Human-readable label for the failure line: the env var, or + /// `VAR.suffix` when the file names something the var alone does not. + site: String, + path: PathBuf, + file: Option, + written: usize, + /// `None` only for a stream whose total length is genuinely unknowable at + /// open time (an append-mode text table). Short-write detection still + /// applies -- `write_all` reports a short write as `Err` -- but the failure + /// line then carries no expected count, because inventing one would be a + /// guess. + expected: Option, +} + +impl LoudDump { + /// Open `path` for `site`, expecting exactly `expected` bytes in total. + /// + /// Failing to CREATE is loud too: a requested dump that does not exist is + /// the same silent hole as one that is short (the reader sees no file, or + /// an empty one), and it is the more common of the two (a missing parent + /// directory, a path a sweep reused as a directory). + pub fn create(site: &str, path: impl AsRef, expected: usize) -> Self { + let path = path.as_ref().to_path_buf(); + let file = File::create(&path).unwrap_or_else(|e| { + abort( + &site, + &path, + 0, + Some(expected), + &format!("could not create the dump file: {e}"), + ) + }); + Self { + site: site.to_string(), + path, + file: Some(file), + written: 0, + expected: Some(expected), + } + } + + /// Open `path` for `site` in APPEND mode with no knowable total length -- + /// the CDF-table text dump, whose file spans every frame of a run. Write + /// errors are still fatal; the length check is simply absent (see + /// [`LoudDump::expected`]). + pub fn append_unknown(site: &str, path: impl AsRef) -> Self { + let path = path.as_ref().to_path_buf(); + let file = OpenOptions::new() + .create(true) + .append(true) + .open(&path) + .unwrap_or_else(|e| { + abort( + &site, + &path, + 0, + None, + &format!("could not open the dump file: {e}"), + ) + }); + Self { + site: site.to_string(), + path, + file: Some(file), + written: 0, + expected: None, + } + } + + /// Hand `chunk` to the file. Overrunning `expected` is a caller bug (the + /// count and the writer disagree) and aborts just as loudly as a short + /// write, because one of the two is certainly lying. + pub fn write(&mut self, chunk: &[u8]) { + if let Some(exp) = self.expected + && self.written + chunk.len() > exp + { + abort( + &self.site, + &self.path, + self.written, + Some(exp), + &format!( + "the writer was handed {} bytes but only {} remained of the {} it declared", + chunk.len(), + exp - self.written, + exp + ), + ); + } + let r = self.file.as_mut().expect("live dump").write_all(chunk); + if let Err(e) = r { + // MEASURED, do not assume: under `RLIMIT_FSIZE` the kernel stores + // everything up to the cap and THEN returns `EFBIG` (measured: + // a 49 152 B frame under caps of 4 KiB / 10 KiB / 30 KiB left + // 4 096 / 10 240 / 30 720 B on disk, with `write_all` confirming + // none of it). So "bytes written" on this line is the file's real + // length, not the count `write_all` got to acknowledge -- the + // acknowledged count rides along in the reason. + let f = self.file.as_ref().expect("live dump"); + let on_disk = f + .metadata() + .map(|m| m.len() as usize) + .unwrap_or(self.written); + abort( + &self.site, + &self.path, + on_disk, + self.expected, + &format!( + "write failed with {} bytes confirmed in hand: {e}", + self.written + ), + ); + } + self.written += chunk.len(); + } + + /// Close the dump: flush, then check the file's own length on disk. + /// + /// The on-disk check is not redundant with the write loop. `write_all` + /// reports what the FILE ACCEPTED, and the reader's question is what the + /// filesystem ended up holding -- a sparse/short final flush, a quota, or a + /// filesystem-level reservation failure all land here rather than in + /// `write`. + pub fn finish(mut self) { + let Some(mut file) = self.file.take() else { return }; + if let Err(e) = file.flush() { + abort( + &self.site, + &self.path, + self.written, + self.expected, + &format!("flush failed after {} bytes: {e}", self.written), + ); + } + let Some(exp) = self.expected else { + return; + }; + let on_disk = match file.metadata() { + Ok(m) => m.len() as usize, + Err(e) => abort( + &self.site, + &self.path, + self.written, + Some(exp), + &format!("could not stat the finished dump: {e}"), + ), + }; + if on_disk != exp { + abort( + &self.site, + &self.path, + on_disk, + Some(exp), + "the file on disk is not the length the writer declared", + ); + } + } +} + +/// The single failure line every short dump now ends on. `site`, the path, the +/// bytes on disk vs the bytes owed, and the reason. +fn abort(site: &str, path: &Path, got: usize, expected: Option, why: &str) -> ! { + let owed = match expected { + Some(e) => format!("{e}"), + None => "an unknown number of".to_string(), + }; + panic!( + "ec-av1 dump FAILED [{}] {}: wrote {} of {} bytes: {}", + site, + path.display(), + got, + owed, + why + ); +} + +/// Write `planes` (already narrowed to their dump's sample width) as ONE dump +/// file, failing loudly on any shortfall. `expected` is the sum of the plane +/// lengths -- the same extents the writer iterates, so a plane that is shorter +/// than its geometry claims cannot hide here. +pub fn write_planes(site: &str, path: impl AsRef, planes: &[&[u8]]) { + let expected: usize = planes.iter().map(|p| p.len()).sum(); + let mut d = LoudDump::create(site, path, expected); + for p in planes { + d.write(p); + } + d.finish(); +} + +#[cfg(test)] +mod tests { + use super::*; + use std::process::Command; + + fn scratch(tag: &str) -> PathBuf { + let p = std::env::temp_dir().join(format!("ec-av1-dumpio-{tag}-{}", std::process::id())); + let _ = std::fs::remove_file(&p); + p + } + + fn caught(f: impl FnOnce() + std::panic::UnwindSafe) -> String { + let prev = std::panic::take_hook(); + std::panic::set_hook(Box::new(|_| {})); + let r = std::panic::catch_unwind(f); + std::panic::set_hook(prev); + let e = r.expect_err("the short dump must abort"); + e.downcast_ref::() + .cloned() + .or_else(|| e.downcast_ref::<&str>().map(|s| (*s).to_string())) + .expect("panic payload is a string") + } + + #[test] + fn success_path_is_byte_identical_to_the_old_write_all_loop() { + let p = scratch("ok"); + let planes: [&[u8]; 3] = [b"abc", b"", b"de"]; + write_planes("T", &p, &planes); + assert_eq!(std::fs::read(&p).unwrap(), b"abcde"); + let _ = std::fs::remove_file(&p); + } + + /// `/dev/full` accepts an `open` for write and returns `ENOSPC` from every + /// write -- the hermetic stand-in for the full filesystem that produced the + /// 13 320 192-byte truncated frame in `lanes/unwritten-dep.report.md`. + #[test] + #[cfg(unix)] + fn full_device_short_write_is_loud() { + let msg = caught(|| write_planes("EC_AV1_FINAL_DUMP", "/dev/full", &[b"abc", b"de"])); + assert!( + msg.starts_with("ec-av1 dump FAILED [EC_AV1_FINAL_DUMP] /dev/full: wrote "), + "{msg}" + ); + assert!(msg.contains("No space left on device"), "{msg}"); + // The counts must be there, or the line does not say what was lost. + assert!(msg.contains(" of 5 bytes"), "{msg}"); + } + + #[test] + fn uncreatable_dump_is_loud() { + let p = std::env::temp_dir().join(format!("ec-av1-nodir-{}/x", std::process::id())); + let msg = caught(|| write_planes("T", &p, &[b"abc"])); + assert!(msg.contains("could not create the dump file"), "{msg}"); + } + + /// A writer that under-declares its own expected length is the same silent + /// hole: the reader gets a file the site believes is complete. + #[test] + fn under_declared_expected_length_is_loud() { + let p = scratch("under"); + let msg = caught(|| { + let mut d = LoudDump::create("T", &p, 2); + d.write(b"abcdef"); + d.finish(); + }); + assert!( + msg.contains("was handed 6 bytes but only 2 remained of the 2 it declared"), + "{msg}" + ); + let _ = std::fs::remove_file(&p); + } + + #[test] + fn append_unknown_takes_no_length_claim() { + let p = scratch("append"); + { + let mut a = LoudDump::append_unknown("T", &p); + a.write(b"x"); + a.finish(); + let mut b = LoudDump::append_unknown("T", &p); + b.write(b"y"); + b.finish(); + } + assert_eq!(std::fs::read(&p).unwrap(), b"xy"); + let msg = caught(|| { + let mut a = LoudDump::append_unknown("T", "/dev/full"); + a.write(b"x"); + a.finish(); + }); + assert!(msg.contains("of an unknown number of bytes"), "{msg}"); + let _ = std::fs::remove_file(&p); + } + /// THE reproduction of the incident this module exists for: a real decode, + /// a real `RLIMIT_FSIZE`, a real truncated `EC_AV1_FINAL_DUMP` file left + /// on disk -- and the run stopping with the bytes-vs-bytes line instead of + /// carrying on to a measurement built on the fragment. + /// + /// `/dev/full` (the unit test above) proves the writer's check works but + /// never leaves a partial file behind, because `create` on it succeeds and + /// nothing is ever stored. `RLIMIT_FSIZE` is the shape + /// `lanes/unwritten-dep.report.md` actually measured: frames 0..4 complete + /// plus 13 320 192 bytes of frame 5. `SIGXFSZ` is IGNORED (`trap "" XFSZ`) + /// so the limit surfaces as `write`'s `EFBIG` -- exactly what a full + /// filesystem's `ENOSPC` does -- instead of killing the child outright. + #[test] + #[cfg(unix)] + fn a_real_decode_under_a_file_size_cap_fails_loudly() { + let dir = std::env::temp_dir().join(format!("ec-av1-dumpio-cap-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + let prefix = dir.join("ours"); + // 8 blocks of 512 B = 4096 B: far below one 256x128 4:2:0 8-bit frame + // (49 152 B), far above the file header, so the write lands and fails + // PART way rather than at create. + let out = Command::new("bash") + .args([ + "-c", + "ulimit -f 8; trap \"\" XFSZ; exec \"$0\" \"$@\"", + // $0 for `bash -c` is the test binary itself. + std::env::current_exe().unwrap().to_str().unwrap(), + "--exact", + "dumpio::tests::dumpio_child_decode", + "--nocapture", + ]) + .env("EC_AV1_DUMPLOUD_CHILD", "1") + .env("EC_AV1_FINAL_DUMP", &prefix) + // One thread, so the dump panic lands on the main thread and the + // child's exit status is the decode's own. + .env("EC_AV1_THREADS", "1") + .output() + .expect("spawning the capped child"); + let stderr = String::from_utf8_lossy(&out.stderr); + assert!( + !out.status.success(), + "the decode must FAIL under a file-size cap, not finish with a truncated dump\n{stderr}" + ); + assert!( + stderr.contains("ec-av1 dump FAILED [EC_AV1_FINAL_DUMP]"), + "the failure line must name the dump site\n{stderr}" + ); + assert!( + stderr.contains("File too large"), + "the failure line must carry the OS error\n{stderr}" + ); + // One 256x128 4:2:0 8-bit frame is 256*128*3/2 = 49 152 B, and the + // failure line's "wrote N of 49152" must name the file's REAL length, + // not the count `write_all` managed to acknowledge: a line that + // under-reports is a line that sends the reader back to the dump to + // measure it themselves. + let frag = std::fs::metadata(format!("{}.f0", prefix.display())) + .unwrap() + .len(); + assert!( + frag < 49152, + "the capped child left a {frag}-byte frame where 49152 B was owed" + ); + assert!( + stderr.contains(&format!("wrote {frag} of 49152 bytes")), + "the failure line's written count must be the file's actual length ({frag})\n{stderr}" + ); + let _ = std::fs::remove_dir_all(&dir); + } + + /// Child half of [`a_real_decode_under_a_file_size_cap_fails_loudly`]. It is + /// not a gate: with no `EC_AV1_DUMPLOUD_CHILD` guard it decodes nothing and + /// asserts nothing, so a plain `cargo test` run is unaffected. + #[test] + fn dumpio_child_decode() { + if std::env::var("EC_AV1_DUMPLOUD_CHILD").is_err() { + return; + } + let path = + std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/420_mixll_256x128_6f.obu"); + let bytes = std::fs::read(&path).expect("the pinned fixture"); + let _ = crate::stream::decode_stream(&bytes); + } +} diff --git a/crates/ec-av1/src/lib.rs b/crates/ec-av1/src/lib.rs index 46308077..199f7cc1 100644 --- a/crates/ec-av1/src/lib.rs +++ b/crates/ec-av1/src/lib.rs @@ -30,6 +30,7 @@ pub mod census; mod compound; pub mod decode; pub mod encode; +mod dumpio; pub mod encoder; mod envflags; mod film_grain; diff --git a/crates/ec-av1/src/msac.rs b/crates/ec-av1/src/msac.rs index 8bdf5440..1b5e0c07 100644 --- a/crates/ec-av1/src/msac.rs +++ b/crates/ec-av1/src/msac.rs @@ -1004,7 +1004,9 @@ pub(crate) mod symtrace { thread_local! { static BUF: RefCell<(String, usize)> = const { RefCell::new((String::new(), 0)) }; static ECD: RefCell> = RefCell::new(VecDeque::new()); - static ECD_READER: RefCell> = const { RefCell::new(None) }; + // lane-av1dumploud: the file's PATH travels with it, so a short write + // can name the file it truncated instead of reconstructing a name. + static ECD_READER: RefCell> = const { RefCell::new(None) }; static ECD_IDX: RefCell = const { RefCell::new(0) }; } @@ -1027,15 +1029,26 @@ pub(crate) mod symtrace { let _ = idx; let line = format!("{idx} ({low},{value},{rng},{bitpos})\n"); ECD_READER.with(|f| { + use std::io::Write; let mut slot = f.borrow_mut(); if slot.is_none() { let seq = SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed); let path = format!("{dir}/ecdump-{seq:05}.txt"); - *slot = Some(std::fs::File::create(&path).expect("ecdump file")); eprintln!("ECDUMP -> {path}"); + *slot = Some((std::fs::File::create(&path).expect("ecdump file"), path)); + } + // lane-av1dumploud: loud on a short write. This file is one line + // per symbol for a whole run, so its total length is unknowable at + // open time -- the failure line says "an unknown number of" rather + // than declaring a length it would have to invent. + let (file, path) = slot.as_mut().expect("just opened"); + if let Err(e) = file.write_all(line.as_bytes()) { + panic!( + "ec-av1 dump FAILED [EC_AV1_ECDUMP] {path}: \ + write failed after a partial line of {} bytes: {e}", + line.len() + ); } - use std::io::Write; - let _ = slot.as_mut().unwrap().write_all(line.as_bytes()); }); ECD.with(|q| { let mut q = q.borrow_mut(); @@ -1119,8 +1132,17 @@ pub(crate) mod symtrace { BUF.with(|b| { let (buf, n) = &mut *b.borrow_mut(); if !buf.is_empty() { + // lane-av1dumploud: loud on a short write. `std::fs::write` + // returns a `Result` that this used to discard; the expected + // length is exactly the buffer's own. let seq = SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed); - let _ = std::fs::write(format!("{dir}/{side}-{seq:05}.txt"), buf.as_bytes()); + let (bytes, at) = (buf.as_bytes(), format!("{dir}/{side}-{seq:05}.txt")); + if let Err(e) = std::fs::write(&at, bytes) { + panic!( + "ec-av1 dump FAILED [EC_AV1_SYMTRACE] {at}: wrote 0 of {} bytes: {e}", + bytes.len() + ); + } } buf.clear(); *n = 0; diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index f5ebc70c..99495dcd 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -2174,22 +2174,23 @@ fn decode_frame( // end-of-tile one. let stored_cdfs = stored_cdfs_for(header, end_cdfs, started_from); if let Ok(path) = std::env::var("EC_AV1_DUMP_TABLES") { - use std::io::Write; - if let Ok(mut f) = std::fs::OpenOptions::new() - .create(true) - .append(true) - .open(&path) - { - let _ = writeln!(f, "=== frame idx={} ===", shown_idx); - let _ = writeln!(f, "partition_w64 {:?}", stored_cdfs.partition_w64); - let _ = writeln!(f, "partition_w32 {:?}", stored_cdfs.partition_w32); - let _ = writeln!(f, "partition_w16 {:?}", stored_cdfs.partition_w16); - let _ = writeln!(f, "skip {:?}", stored_cdfs.skip); - let _ = writeln!(f, "new_mv {:?}", stored_cdfs.new_mv); - let _ = writeln!(f, "zero_mv {:?}", stored_cdfs.zero_mv); - let _ = writeln!(f, "ref_mv {:?}", stored_cdfs.ref_mv); - let _ = writeln!(f, "mv_joint {:?}", stored_cdfs.mv_joint); - } + // lane-av1dumploud: loud on a short write. This one is APPEND-mode and + // spans every frame of a run, so there is no total length to declare + // (`append_unknown` says so on the failure line rather than guessing + // one); the per-line writes are still checked, so an ENOSPC halfway + // through a table no longer passes as a complete one. + let mut f = crate::dumpio::LoudDump::append_unknown("EC_AV1_DUMP_TABLES", &path); + let mut line = |s: String| f.write(s.as_bytes()); + line(format!("=== frame idx={shown_idx} ===\n")); + line(format!("partition_w64 {:?}\n", stored_cdfs.partition_w64)); + line(format!("partition_w32 {:?}\n", stored_cdfs.partition_w32)); + line(format!("partition_w16 {:?}\n", stored_cdfs.partition_w16)); + line(format!("skip {:?}\n", stored_cdfs.skip)); + line(format!("new_mv {:?}\n", stored_cdfs.new_mv)); + line(format!("zero_mv {:?}\n", stored_cdfs.zero_mv)); + line(format!("ref_mv {:?}\n", stored_cdfs.ref_mv)); + line(format!("mv_joint {:?}\n", stored_cdfs.mv_joint)); + f.finish(); } // lane-comppin r3: decode-order (not display-order) dump of every // frame's own post-deblock buffer -- the pre-existing pixel diff @@ -2202,17 +2203,19 @@ fn decode_frame( // to isolate whether the defect is in a hidden frame's own // reconstruction or downstream of it. if let Ok(path) = std::env::var("EC_AV1_DECODE_ORDER_DUMP") { - use std::io::Write; - let idx = decode_idx; - if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) { - // lane-hbd r4: debug dump narrows to u8 -- this diagnostic - // predates 10-bit support and is an 8-bit-oracle comparison - // only (aomdec's own dump is 8-bit here too). - let narrow = |v: &[u16]| -> Vec { v.iter().map(|&s| s as u8).collect() }; - let _ = f.write_all(&narrow(&picture.y)); - let _ = f.write_all(&narrow(&picture.u)); - let _ = f.write_all(&narrow(&picture.v)); - } + // lane-hbd r4: debug dump narrows to u8 -- this diagnostic + // predates 10-bit support and is an 8-bit-oracle comparison + // only (aomdec's own dump is 8-bit here too). + // + // lane-av1dumploud: loud on a short write; expected length is the three + // planes' own lengths (narrowing is 1 byte per sample, so the count is + // unchanged). + let narrow = |v: &[u16]| -> Vec { v.iter().map(|&s| s as u8).collect() }; + crate::dumpio::write_planes( + "EC_AV1_DECODE_ORDER_DUMP", + format!("{path}.f{decode_idx}"), + &[&narrow(&picture.y), &narrow(&picture.u), &narrow(&picture.v)], + ); } // lane-hidden r1: the frame exactly as it is about to be stored into // the reference slots -- after deblock/CDEF/LR/superres, in DECODE @@ -2247,20 +2250,27 @@ fn decode_frame( // stores and every later frame predicts from. decode::census_unwritten_final(&picture.y, &picture.u, &picture.v); if let Some(prefix) = final_dump { - use std::io::Write; - if let Ok(mut f) = std::fs::File::create(format!("{prefix}.f{decode_idx}")) { - let mut buf = Vec::new(); - for plane in [&picture.y, &picture.u, &picture.v] { - if bit_depth == 8 { - buf.extend(plane.iter().map(|&s| s as u8)); - } else { - for &s in plane { - buf.extend_from_slice(&s.to_le_bytes()); - } + // lane-av1dumploud: this is the site that produced the 13 320 192-byte + // truncated frame in `lanes/unwritten-dep.report.md` -- `let _ = + // f.write_all(&buf)` swallowed the ENOSPC. Expected length is derived + // from the PLANES and the sample width, independently of `buf`, so a + // writer that builds the wrong buffer still gets caught. + let sample_width = if bit_depth == 8 { 1 } else { 2 }; + let expected = (picture.y.len() + picture.u.len() + picture.v.len()) * sample_width; + let mut f = + crate::dumpio::LoudDump::create("EC_AV1_FINAL_DUMP", format!("{prefix}.f{decode_idx}"), expected); + for plane in [&picture.y, &picture.u, &picture.v] { + if bit_depth == 8 { + f.write(&plane.iter().map(|&s| s as u8).collect::>()); + } else { + let mut row = Vec::with_capacity(plane.len() * 2); + for &s in plane { + row.extend_from_slice(&s.to_le_bytes()); } + f.write(&row); } - let _ = f.write_all(&buf); } + f.finish(); } Ok(FrameOutput { picture, diff --git a/lanes/av1dumploud.report.md b/lanes/av1dumploud.report.md new file mode 100644 index 00000000..fd3351fa --- /dev/null +++ b/lanes/av1dumploud.report.md @@ -0,0 +1,284 @@ +# lane/av1dumploud — every dump site fails loudly on a short write + +**Outcome in one line:** all 11 dump write sites in `crates/ec-av1` now account +for their own byte count and abort the run with the file, the bytes on disk, the +bytes owed and the OS error; one real decode under a real `RLIMIT_FSIZE` is +reproduced as a FAILING run; the `reelb_rect64_intra16x4_witness` hash sweep is +byte-identical to `lanes/unwritten-dep.report.md` §2 with the loud writer in +place; the campaign value `0ee1edf403` is **still not reproduced** and stays open +with the mechanism class now provably closed going forward. + +Base: `f01e9738`. Branch: `lane/av1dumploud`. Worktree: +`/home/user/.cache/wt/av1dumploud`. Target dir: +`/home/user/.cache/target-av1dumploud`. + +The class this lane closes is named in `lanes/unwritten-dep.report.md` §9 as an +open item: *"The dump sites still swallow their write errors, so a short dump +remains possible — the artefact behind §3."* That is now closed for every site. + +--- + +## 1. Every dump write site, and what a FULL write means for it + +New module: `crates/ec-av1/src/dumpio.rs`. `LoudDump::create(site, path, +expected)` opens the file, `write(chunk)` hands it bytes, `finish()` flushes and +then compares the file's **own length on disk** against `expected`. Any shortfall, +and any failure to create the file at all, panics with one fixed line: + +```text +ec-av1 dump FAILED [] : wrote of bytes: +``` + +| # | Site (file:fn) | Env var | File | Dump shape | FULL write = | +|---|---|---|---|---|---| +| 1 | `decode.rs:21147` `dump_stage16` | `EC_AV1_PREFILT_DUMP16`, `EC_AV1_POSTDEBLOCK_DUMP16`, `EC_AV1_POSTCDEF_DUMP16` | `.f` | luma + 2 chroma, u16 LE, cropped | `(fw*fh + 2*cw*ch) * 2`, `cw = round_ss(fw, ss_x)`, `ch = round_ss(fh, ss_y)` — the same per-axis extents the writer slices | +| 2 | `decode.rs:21235` `dump_stage` | `EC_AV1_POSTDEBLOCK_DUMP`, `EC_AV1_POSTCDEF_DUMP` | `.f` | whole padded plane, u8 | `y.data.len() + u.data.len() + v.data.len()` | +| 3 | `decode.rs:21259` `dump_prefilter_wide` | `EC_AV1_PREFILT_WIDE_DUMP` | `.f` | mi-aligned crop, u8 | `Σ true_width * true_height` over the three planes | +| 4 | `decode.rs:38237` (key-frame twin) | `EC_AV1_PREFILT_DUMP` | `.f` | whole padded plane, u8 | `Σ p.data.len()` | +| 5 | `decode.rs:56608` (inter-frame twin) | `EC_AV1_PREFILT_DUMP` | `.f` | whole padded plane, u8 | `Σ p.data.len()` | +| 6 | `decode.rs:38471` margin dump | `EC_AV1_MARGIN_DUMP` | `.f` | `true_width x true_height` luma crop, u8 | `true_width * true_height` | +| 7 | `stream.rs:2205` | `EC_AV1_DECODE_ORDER_DUMP` | `.f` | post-deblock, u8-narrowed | `y.len() + u.len() + v.len()` (narrowing is 1 B/sample) | +| 8 | `stream.rs:2252` | `EC_AV1_FINAL_DUMP` | `.f` | post-filter/superres, bit-depth correct | `(y.len() + u.len() + v.len()) * sample_width`, `sample_width = 1` at 8-bit else 2 — computed from the PLANES, not from the buffer, so a wrong buffer is still caught | +| 9 | `stream.rs:2176` | `EC_AV1_DUMP_TABLES` | `` (APPEND) | 9 text lines per frame, one file for the whole run | **CANNOT BE KNOWN** — the file spans every frame, so no total length exists to declare. `append_unknown` says `of an unknown number of bytes` on the failure line instead of inventing one. Per-line write errors are still fatal. | +| 10 | `msac.rs:1031` `symtrace::ecdump` | `EC_AV1_ECDUMP` | `/ecdump-.txt` | one text line per symbol, streamed for a whole run | **CANNOT BE KNOWN** — same reason; the file grows per symbol. Write errors are fatal and the line is named (the path now travels with the handle). | +| 11 | `msac.rs:1130` `symtrace::flush` | symtrace dir | `/-.txt` | one coder's buffered lines | `buf.len()` — `std::fs::write` returned a `Result` that was discarded; now fatal. **Result-only**: see the note under the table. | + +**Row 11 is the one site verified by `Result` alone.** `std::fs::write` returns +only a `Result`, so unlike the other ten there is no handle to keep, no +`finish()`, and no second look at the file's own length on disk. It is still +loud on a short write — `Err` is fatal — but its check is the `Result` and +nothing more. Do not read the table's "FULL write" column as identical +verification for all eleven: rows 1–10 are checked twice (bytes handed in, then +the file on disk), row 11 once. + +**Out of scope, named rather than skipped.** Three shapes: + +* **Nine `#[cfg(test)]` stream-pin sites** — `stream.rs` ≈ 14191, 18201, 23170, + 23190, 23589, 23611, 27904, 28896, 29106. Each does `let _ = std::fs::write( + &pin, &stream)` and then `panic!`s on the next line naming the pin. **A + truncated pin is a live residue here, and it is not fixed by this lane**: the + write result is discarded, so an `ENOSPC` or an `RLIMIT_FSIZE` hit partway + through a multi-megabyte `.obu` leaves a SHORT stream at exactly the path the + following `panic!` hands the reader ("stream pinned at {}"). "No decode + measurement is built on the file" is true of the test's VERDICT — which comes + from the assert, not the artefact — and is not true of the artefact. Named, not + fixed: these are test-side pins, and making them loud would change what a + failing gate prints rather than what a failing gate decides. +* **`stream.rs:28143`**, the tenth pin site and a different shape: it checks the + `Result`, but **warns and continues** — `eprintln!("cdfflake: could not pin to + {}: {e}", …)` — by explicit design, because its own comment says a failed + write must not mask the assert below it. So neither the "they panic on the next + line" reason above nor the "discards the result" one applies to it. It is + excluded on the same ground as the nine (a `#[cfg(test)]` pin whose verdict + comes from the assert), with the extra note that its own failure path is + already deliberate and non-fatal. +* **`probe.rs:158`**: a stdin pipe to a child process, swallowed on purpose so + the child's own exit status and stderr carry the diagnosis (the documented + `aomenc-stdin` deadlock fix). Not a file at all. + +### Success path + +Byte-identical, by construction: same bytes, same order, same file names, same +per-var index (`dump_stage_idx` is still only called when the var is set, and +still once per frame). `dumpio::tests::success_path_is_byte_identical_to_the_old_write_all_loop` +pins the three-plane concatenation, and §4's sweep pins the real geometry: every +frame of both 10-bit witnesses is exactly 18 524 160 B, unchanged. + +### The one behaviour change visible without a disk error + +**A dump that cannot be CREATED is now fatal too** (missing parent directory, a +path a sweep reused as a directory). It is the same silent hole as a short dump +— the reader sees no file, or an empty one — and it is the more common of the +two. This only fires when the operator has explicitly set the env var. + +--- + +## 2. The reproduced short write + +`RLIMIT_FSIZE` is the shape `lanes/unwritten-dep.report.md` §3 actually measured +(frames 0..4 complete plus 13 320 192 B of frame 5). `SIGXFSZ` is **ignored** +(`trap "" XFSZ`) so the limit surfaces as `write`'s `EFBIG` — exactly what a full +filesystem's `ENOSPC` does — instead of killing the child. Committed gate: +`dumpio::tests::a_real_decode_under_a_file_size_cap_fails_loudly`, which drives a +real decode of the pinned `420_mixll_256x128_6f.obu` in a child process under a +4 KiB cap and asserts the run FAILS. + +Captured output (same child, three caps; one 256×128 4:2:0 8-bit frame owes +49 152 B): + +``` +=== ulimit -f 8 (4096 B) === +ec-av1 dump FAILED [EC_AV1_FINAL_DUMP] …/ours.f0: wrote 4096 of 49152 bytes: write failed with 0 bytes confirmed in hand: File too large (os error 27) +child exit=101 ours.f0 = 4096 B + +=== ulimit -f 20 (10240 B) === +ec-av1 dump FAILED [EC_AV1_FINAL_DUMP] …/ours.f0: wrote 10240 of 49152 bytes: write failed with 0 bytes confirmed in hand: File too large (os error 27) +child exit=101 ours.f0 = 10240 B + +=== ulimit -f 60 (30720 B) === +ec-av1 dump FAILED [EC_AV1_FINAL_DUMP] …/ours.f0: wrote 30720 of 49152 bytes: write failed with 0 bytes confirmed in hand: File too large (os error 27) +child exit=101 ours.f0 = 30720 B + +=== uncapped === +child exit=0 ours.f0 … ours.f6 = 49152 B each +``` + +Two things this measurement corrected, and would have got wrong by assumption: + +1. **The kernel stores up to the cap and THEN returns `EFBIG`** — `write_all` + confirms *none* of it. The naive "bytes acknowledged" count would have printed + `wrote 0` while 30 720 B sat on disk. The failure line therefore reports the + file's **measured length on disk**, and carries the acknowledged count + separately ("0 bytes confirmed in hand"). The gate asserts the reported number + EQUALS the fragment's real length, so the line cannot drift from the artefact. +2. The empty-file variant of the incident ("an empty dump read as + instability") is the `wrote 0` end of the same sweep, not a separate case. + +Supporting gates (`crates/ec-av1/src/dumpio.rs`): `/dev/full` (hermetic `ENOSPC`, +no bytes stored), an uncreatable path, a writer that under-declares its own +expected length, and the append-unknown case asserting the "unknown number of" +wording. + +--- + +## 3. `0ee1edf403` — still not reproduced, and now bounded + +Re-attempted on `reelb_rect64_intra16x4_witness.obu` (23 472 B, sha256 +`c9e721088766163b…`) with the loud writer in place. + +```text +--- A. plain, 3 processes --- + rc=0 sha=a26438168c3c53a0 frames=34 ×3, identical +--- B. sentinel (EC_AV1_PLANE_SENTINEL=1), 3 processes --- + rc=0 sha=a26438168c3c53a0 frames=34 ×3, identical +--- C. two decodes CONCURRENTLY into one reused directory --- + rc=0/0 sha=a26438168c3c53a0 frames=34 +--- D. RLIMIT_FSIZE sweep --- + cap=32768B rc=101 wrote 65536 of 18524160 bytes sha=2d3745b17d665bed frames=1 + cap=65536B rc=101 wrote 131072 of 18524160 bytes sha=1fd52689ef20fb22 frames=1 + cap=262144B rc=101 wrote 524288 of 18524160 bytes sha=5d13ba5d22458efb frames=1 + cap=1048576B rc=101 wrote 2097152 of 18524160 bytes sha=5f745dcff3520f78 frames=1 + cap=2097152B rc=101 wrote 4194304 of 18524160 bytes sha=0aafa68194719c7c frames=1 + cap=4194304B rc=101 wrote 8388608 of 18524160 bytes sha=7cab950993a6fcc7 frames=1 + cap=8388608B rc=101 wrote 16777216 of 18524160 bytes: + write failed with 15436800 bytes confirmed in hand + sha=1bf8cc62449548a5 frames=1 + cap=16777216B rc=0 sha=a26438168c3c53a0 frames=34 +--- E. truncated-prefix arithmetic sweep --- + 34 frames of 18524160 B, full stream 629821440 B + shapes checked: whole stream + 34 whole-frame prefixes + + 34 × {1/4, 1/512, 1/1024, 1/4096, 1/65536} partial cuts → matches: 0 +``` + +**What the new evidence RULES OUT (mechanism class, not the value):** any dump +truncated by a filesystem-full, quota or `RLIMIT_FSIZE` failure. Seven caps were +swept; every truncating one now ABORTS with the bytes-vs-expected line instead of +leaving an artefact, and none of the seven artefacts that did get written on the +way down hashes to `0ee1edf403`. The `cap=8388608B` row is the campaign's own +reported shape — complete frames plus a partial tail — now with the confirmed +prefix count in the line. The concurrent-reuse shape is likewise closed here: +both processes exited 0 with every frame at full length. + +**What it does NOT rule out, stated plainly:** + +* **A killed process.** `SIGKILL`/`SIGTERM` between two frame writes runs no code, + so no failure line can be emitted and the artefact is exactly the prefix. The + loud writer cannot see this; nothing in this lane can. A timeout-killed campaign + run remains a live explanation. +* **A different build or host.** `0ee1edf403` never reproduced on *any* tree + measured, plain or sentinel; the campaign's own PLAIN value reproduces here, + which means the divergence was already present in its plain runs too. +* **The value itself.** `0ee1edf403` remains an unreproduced 10-hex artefact + after 34 whole-frame prefixes, 170 partial cuts, 3 plain and 3 sentinel + processes, and a concurrent reuse. **Not closed, and not closed by assertion.** + +**Disposition: OPEN (instrument hygiene).** The decode remains invariant — plain +and sentinel agree, 3/3 and 3/3, in 34 frames of exactly 18 524 160 B — so nothing +here makes it a decoder defect. What changed is that one whole family of +explanations (silent truncation) is now closed at the instrument, so the next +attempt does not have to re-sweep it. + +--- + +## 4. The sweep whose hashes must not move + +`reelb_rect64_intra16x4_witness` and `reelb_arf_witness`, one decode per PROCESS, +decode-order `cat frame.f*` hashed, every frame's size read back: + +```text +reelb_rect64_intra16x4_witness run1 rc=0 frames=34 sizes=[18524160] sha=a26438168c3c53a0 +reelb_rect64_intra16x4_witness run2 rc=0 frames=34 sizes=[18524160] sha=a26438168c3c53a0 +reelb_rect64_intra16x4_witness run3 rc=0 frames=34 sizes=[18524160] sha=a26438168c3c53a0 +reelb_arf_witness run1 rc=0 frames=40 sizes=[18524160] sha=8d7a43bc5fcf840a +reelb_arf_witness run2 rc=0 frames=40 sizes=[18524160] sha=8d7a43bc5fcf840a +reelb_arf_witness run3 rc=0 frames=40 sizes=[18524160] sha=8d7a43bc5fcf840a +``` + +Against `lanes/unwritten-dep.report.md` §2: `a26438168c` and `8d7a43bc5f` — +**unchanged, prefix for prefix, with the loud writer in place.** The frame size +18524160 is the one §2/§10 assert by hand; it is now asserted by the writer on +every single frame, so a sweep can no longer "pass" a short one. + +--- + +## 5. Gates run + +``` +cargo test -p ec-av1 --lib -- dump + dumpio::tests::a_real_decode_under_a_file_size_cap_fails_loudly ... ok + dumpio::tests::full_device_short_write_is_loud ... ok + dumpio::tests::success_path_is_byte_identical_to_the_old_write_all_loop ... ok + dumpio::tests::append_unknown_takes_no_length_claim ... ok + dumpio::tests::uncreatable_dump_is_loud ... ok + dumpio::tests::under_declared_expected_length_is_loud ... ok + stream::tests::pinned_lr_sgr_stream_call_unique_dump ... ok + wedge::tests::wedge_codebook_matches_libaom_dump ... ok + intra::tests::rect_predictors_match_c_dump ... ok + test result: ok. 10 passed; 0 failed; 0 ignored +``` +cargo test -p ec-av1 --lib -- the_frame_the_caller_receives_carries_no_unwritten_plane_sample + test result: ok. 1 passed; 0 failed (71 s) +``` + +`dumpio::tests::dumpio_child_decode` is the child half of the RLIMIT gate. It is +not a gate: with no `EC_AV1_DUMPLOUD_CHILD` guard it decodes nothing and asserts +nothing, so a plain `cargo test` run is unaffected. + +Full-crate validation is Main's job and was not run here (sibling lanes are +editing concurrently). + +--- + +## 6. What this lane did not do + +* Did not close `0ee1edf403`. See §3 for what is and is not ruled out. +* Did not touch the reserved 4:2:0 group-tail chroma SKIP arm, `film_grain.rs`, + or any decode semantics. The only behavioural changes are: a dump that cannot + be written now ends the run, and a dump that cannot be created now ends the run. +* Did not change what any dump CONTAINS, or its file naming or index. +* Did not add `dumpio` to the public API (`mod dumpio`, private) — it is an + instrument, not a surface. +* Did not sweep the pinned `440_request_is_422` cell: `main` = `f01e9738` + refuses it, same as `e45cc748` did in §10. +* **Did not make the ten `#[cfg(test)]` stream pins loud** (§1, "Out of + scope"). A short write to one of them leaves a truncated `.obu` at exactly the + path the following `panic!` hands the reader. Named residue, deliberately not + fixed here: these are test-side pins whose verdict comes from the assert, not + from the file, and the one site that already handles its own failure + (`stream.rs:28143`) does so by design. If a lane wants them closed, the shape + is `LoudDump::create(site, path, stream.len())` — the same three lines as the + eleven — but it is a change to what a FAILING GATE PRINTS, and that is a + decision for the owner of the gates, not for an instrument lane. + +## 7. Coordination + +Peer lane `av1uballoc` owns `fresh_plane` in `decode.rs` (~21820–21860, the +`plane_sentinel_on()` allocation path). Untouched by this lane. + +Lines this lane changed in `crates/ec-av1/src/decode.rs`: **21156–21215** +(`dump_stage16`), **21217–21250** (`dump_stage`), **21250–21284** +(`dump_prefilter_wide`), **38237–38252** (key-frame `EC_AV1_PREFILT_DUMP`), +**38471–38488** (`EC_AV1_MARGIN_DUMP`), **56608–56623** (inter-frame +`EC_AV1_PREFILT_DUMP`). Plus `stream.rs` 2176–2194, 2205–2219, 2252–2274; +`msac.rs` 1007–1009, 1031–1052, 1135–1146; `lib.rs` 33; new file +`src/dumpio.rs`. \ No newline at end of file