forge
Explore
Log in

Don't you dare go Hollow

Merge lane/av1dumploud: a short dump is now loud, at every dump site

Browse files at this commit

841ad8036d04a8037ab184218bccd8d52cd7364eAhmet Kaan GümüşParent: a18289e286530d
Every dump site used to write with `let _ = f.write_all(...)`. A full filesystem, an
RLIMIT_FSIZE, or any ENOSPC therefore left a TRUNCATED dump and nothing said so -- and that
artefact is what produced two false defect rows earlier today (`reelb_arf_witness`'s sentinel
hash reproduces bit-for-bit as frames 0..4 plus a 13320192-byte frame 5) and an empty dump
that read as instability.

Eleven sites now declare their expected byte count and abort with the file, the bytes on
disk, the bytes owed and the OS error. Two sites say plainly that they cannot know a total
(the append-mode table dump has no end-of-run close; the ECDUMP handle is never dropped)
rather than guessing.

The proof is a real decode under a real RLIMIT_FSIZE, and it corrected the mechanism: the
kernel stores up to the cap and only then returns EFBIG, with write_all confirming none of
it, so an acknowledged-bytes count printed "wrote 0" over a 30720-byte file. The failure
line therefore reports the file's measured on-disk length and carries the acknowledged
count separately.

A sweep re-run with the loud writer in place is byte-identical to the earlier report
(a26438168c3c53a0 / 8d7a43bc5fcf840a, sizes [18524160], now asserted per frame). The
unexplained campaign value 0ee1edf403 stays open with the new evidence named.
crates/ec-av1/src/decode.rsmodified+66 -40
@@ -21154,7 +21154,6 @@ fn dump_stage16(
21154 ss_x: usize,21154 ss_x: usize,
21155 ss_y: usize,21155 ss_y: usize,
21156 ) {21156 ) {
21157- use std::io::Write;
21158 // lane-sbrect10 r2 / lane-cdef r1 (one shared helper): index the dump by21157 // lane-sbrect10 r2 / lane-cdef r1 (one shared helper): index the dump by
21159 // decode-order picture like EC_AV1_PREFILT_DUMP already does -- a fixed21158 // decode-order picture like EC_AV1_PREFILT_DUMP already does -- a fixed
21160 // `.f0` name kept only the LAST frame, so a mid-sequence divergence could21159 // `.f0` name kept only the LAST frame, so a mid-sequence divergence could
@@ -21173,25 +21172,36 @@ fn dump_stage16(
21173 // the same rounding the21172 // the same rounding the
21174 // decoder's own plane extents use, and it matches the oracle's21173 // decoder's own plane extents use, and it matches the oracle's
21175 // `uv_crop_width` / `uv_crop_height` per axis.21174 // `uv_crop_width` / `uv_crop_height` per axis.
21175+ //
21176 // ONE file per frame: `dump_stage_idx` advances on every call, so creating21176 // ONE file per frame: `dump_stage_idx` advances on every call, so creating
21177 // the file inside the plane loop would write three files per frame and21177 // the file inside the plane loop would write three files per frame and
21178 // shift every later frame's index.21178 // shift every later frame's index.
21179- if let Ok(path) = crate::envflags::var(var)21179+ //
21180- && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var)))21180+ // lane-av1dumploud: this used to be `let _ = f.write_all(&bytes)` per row, so
21181- {21181+ // a full filesystem left a SHORT file that no reader could tell from a
21182- for (p, w, h) in [21182+ // complete one. `LoudDump` is given the exact expected length this function
21183- (y, fw, fh),21183+ // knows -- `(fw*fh + 2*cw*ch) * 2`, u16 LE -- and checks it against the file
21184- (u, round_ss(fw, ss_x), round_ss(fh, ss_y)),21184+ // on disk; a shortfall aborts the decode instead of leaving a plausible
21185- (v, round_ss(fw, ss_x), round_ss(fh, ss_y)),21185+ // artefact behind.
21186- ] {21186+ if let Ok(path) = crate::envflags::var(var) {
21187+ let cw = round_ss(fw, ss_x);
21188+ let ch = round_ss(fh, ss_y);
21189+ let expected = (fw * fh + 2 * cw * ch) * 2;
21190+ let mut d = crate::dumpio::LoudDump::create(
21191+ var,
21192+ format!("{path}.f{}", dump_stage_idx(var)),
21193+ expected,
21194+ );
21195+ for (p, w, h) in [(y, fw, fh), (u, cw, ch), (v, cw, ch)] {
21187 for row in 0..h {21196 for row in 0..h {
21188 let mut bytes = Vec::with_capacity(w * 2);21197 let mut bytes = Vec::with_capacity(w * 2);
21189 for &s in &p.data[row * p.width..][..w] {21198 for &s in &p.data[row * p.width..][..w] {
21190 bytes.extend_from_slice(&s.to_le_bytes());21199 bytes.extend_from_slice(&s.to_le_bytes());
21191 }21200 }
21192- let _ = f.write_all(&bytes);21201+ d.write(&bytes);
21193 }21202 }
21194 }21203 }
21204+ d.finish();
21195 }21205 }
21196 }21206 }
21197 21207
@@ -21214,14 +21224,17 @@ fn dump_stage_idx(var: &str) -> usize {
21214 }21224 }
21215 21225
21216 fn dump_stage(var: &str, y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) {21226 fn dump_stage(var: &str, y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) {
21217- use std::io::Write;21227+ // lane-av1dumploud: loud on a short write (see [`crate::dumpio::LoudDump`]).
21218- if let Ok(path) = crate::envflags::var(var)21228+ // The expected length is the three planes' own data lengths -- the writer
21219- && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var)))21229+ // iterates exactly `p.data`, so this is the same extent, not a re-derivation
21220- {21230+ // that could disagree with it.
21221- for p in [y, u, v] {21231+ if let Ok(path) = crate::envflags::var(var) {
21222- let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect();21232+ let narrow = |p: &PlaneBuf<'_>| -> Vec<u8> { p.data.iter().map(|&s| s as u8).collect() };
21223- let _ = f.write_all(&narrow);21233+ crate::dumpio::write_planes(
21224- }21234+ var,
21235+ format!("{path}.f{}", dump_stage_idx(var)),
21236+ &[&narrow(y), &narrow(u), &narrow(v)],
21237+ );
21225 }21238 }
21226 }21239 }
21227 21240
@@ -21247,7 +21260,9 @@ fn dump_prefilter_wide(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) {
21247 let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_WIDE_DUMP") else {21260 let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_WIDE_DUMP") else {
21248 return;21261 return;
21249 };21262 };
21250- use std::io::Write;21263+ // lane-av1dumploud: loud on a short write. Expected length is
21264+ // `sum(true_width * true_height)` over the three planes -- the crop the
21265+ // writer itself builds, so the check cannot disagree with the bytes.
21251 let idx = dump_stage_idx("EC_AV1_PREFILT_WIDE_DUMP");21266 let idx = dump_stage_idx("EC_AV1_PREFILT_WIDE_DUMP");
21252 let crop = |plane: &PlaneBuf<'_>| -> Vec<u8> {21267 let crop = |plane: &PlaneBuf<'_>| -> Vec<u8> {
21253 let mut out = Vec::with_capacity(plane.true_width * plane.true_height);21268 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<'_>) {
21260 }21275 }
21261 out21276 out
21262 };21277 };
21263- if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) {21278+ let (cy, cu, cv) = (crop(y), crop(u), crop(v));
21264- let _ = f.write_all(&crop(y));21279+ crate::dumpio::write_planes(
21265- let _ = f.write_all(&crop(u));21280+ "EC_AV1_PREFILT_WIDE_DUMP",
21266- let _ = f.write_all(&crop(v));21281+ format!("{path}.f{idx}"),
21267- }21282+ &[&cy, &cu, &cv],
21283+ );
21268 }21284 }
21269 21285
21270 /// Enabled by `EC_AV1_PLANE_SENTINEL` (there is no separate flag for it): print21286 /// 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(
38218 );38234 );
38219 census_unwritten(&y, &u, &v);38235 census_unwritten(&y, &u, &v);
38220 if let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_DUMP") {38236 if let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_DUMP") {
38221- use std::io::Write;38237+ // lane-av1dumploud: loud on a short write (three discarded
38238+ // `write_all` results before). Expected length = the three planes' own
38239+ // data lengths: this dump is the PADDED plane, not a crop, so the
38240+ // writer's extent is `p.data` itself.
38222 let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);38241 let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
38223- if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) {
38224 let narrow =38242 let narrow =
38225 |p: &PlaneBuf<'_>| -> Vec<u8> { p.data.iter().map(|&s| s as u8).collect() };38243 |p: &PlaneBuf<'_>| -> Vec<u8> { p.data.iter().map(|&s| s as u8).collect() };
38226- let _ = f.write_all(&narrow(&y));38244+ crate::dumpio::write_planes(
38227- let _ = f.write_all(&narrow(&u));38245+ "EC_AV1_PREFILT_DUMP",
38228- let _ = f.write_all(&narrow(&v));38246+ format!("{path}.f{idx}"),
38229- }38247+ &[&narrow(&y), &narrow(&u), &narrow(&v)],
38248+ );
38230 } else {38249 } else {
38231 PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);38250 PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
38232 }38251 }
@@ -38449,16 +38468,22 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
38449 *m.borrow_mut() = if true_width > fw || true_height > fh {38468 *m.borrow_mut() = if true_width > fw || true_height > fh {
38450 let yc = crop(&y, true_width, true_height);38469 let yc = crop(&y, true_width, true_height);
38451 if let Ok(path) = crate::envflags::var("EC_AV1_MARGIN_DUMP") {38470 if let Ok(path) = crate::envflags::var("EC_AV1_MARGIN_DUMP") {
38452- use std::io::Write;
38453 static IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);38471 static IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
38454 let idx = IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);38472 let idx = IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
38455- if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) {
38456 // corner-cut: this diagnostic dump stays 8-bit-narrowed38473 // corner-cut: this diagnostic dump stays 8-bit-narrowed
38457 // regardless of the stream's real bit depth (debug-only,38474 // regardless of the stream's real bit depth (debug-only,
38458 // never read by a gate); widen if a >8-bit margin dump38475 // never read by a gate); widen if a >8-bit margin dump
38459 // is ever needed.38476 // is ever needed.
38460- let _ = f.write_all(&yc.iter().map(|&s| s as u8).collect::<Vec<u8>>());38477+ //
38461- }38478+ // lane-av1dumploud: loud on a short write. Expected length is
38479+ // `true_width * true_height` -- the crop this dump is exactly,
38480+ // not a re-derived geometry.
38481+ let narrow: Vec<u8> = yc.iter().map(|&s| s as u8).collect();
38482+ crate::dumpio::write_planes(
38483+ "EC_AV1_MARGIN_DUMP",
38484+ format!("{path}.f{idx}"),
38485+ &[&narrow],
38486+ );
38462 }38487 }
38463 Some(Picture {38488 Some(Picture {
38464 width: true_width,38489 width: true_width,
@@ -56586,15 +56611,16 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
56586 );56611 );
56587 census_unwritten(&y, &u, &v);56612 census_unwritten(&y, &u, &v);
56588 if let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_DUMP") {56613 if let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_DUMP") {
56589- use std::io::Write;56614+ // lane-av1dumploud: loud on a short write (see the key-frame twin
56615+ // above -- same file, same shape, same three planes).
56590 let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);56616 let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
56591- if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) {
56592 let narrow =56617 let narrow =
56593 |p: &PlaneBuf<'_>| -> Vec<u8> { p.data.iter().map(|&s| s as u8).collect() };56618 |p: &PlaneBuf<'_>| -> Vec<u8> { p.data.iter().map(|&s| s as u8).collect() };
56594- let _ = f.write_all(&narrow(&y));56619+ crate::dumpio::write_planes(
56595- let _ = f.write_all(&narrow(&u));56620+ "EC_AV1_PREFILT_DUMP",
56596- let _ = f.write_all(&narrow(&v));56621+ format!("{path}.f{idx}"),
56597- }56622+ &[&narrow(&y), &narrow(&u), &narrow(&v)],
56623+ );
56598 } else {56624 } else {
56599 PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);56625 PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
56600 }56626 }
crates/ec-av1/src/dumpio.rsadded+399 -0
@@ -0,0 +1,399 @@
1+//! Loud dump writing: a dump that cannot hold every byte it claims to hold is
2+//! a failure, not a diagnostic artefact.
3+//!
4+//! lane-av1dumploud: every dump site in this crate wrote through
5+//! `let _ = f.write_all(..)`. A full filesystem, an `RLIMIT_FSIZE`, or any other
6+//! `ENOSPC`/`EFBIG` therefore left a SHORT file on disk and nothing said so.
7+//! Measured consequence, twice in one day: a sentinel-vs-plain hash difference
8+//! that read as decoder nondeterminism reproduced bit-for-bit as a truncated
9+//! dump (`lanes/unwritten-dep.report.md`: frames 0..4 complete plus 13 320 192
10+//! bytes of frame 5, with `EC_AV1_FINAL_DUMP`'s discarded write error), and an
11+//! empty dump read as instability. That artefact started a whole defect class,
12+//! and a silently wrong diagnostic is worse than a loud one, so every dump site
13+//! goes through [`LoudDump`]: the caller states the expected byte count from the
14+//! geometry it already has, the writer checks that count twice -- once against
15+//! the bytes it was handed, once against the file's own length on disk -- and
16+//! any shortfall aborts the decode with the file, the counts, and the OS error.
17+//!
18+//! The success path is byte-identical to the old `write_all` loop: same bytes,
19+//! same order, same file names.
20+//!
21+//! The failure path is a panic, not a returned `Result`: the dump sites sit in
22+//! the middle of `fn decode_*` functions with no error channel for them, and a
23+//! dump that failed IS a decode failure (the run's measurement is void). This
24+//! is a debug instrument -- it only runs when its env var is set -- so the
25+//! panic cannot affect a normal decode.
26+
27+use std::fs::{File, OpenOptions};
28+use std::io::Write;
29+use std::path::{Path, PathBuf};
30+
31+/// One dump file, with the byte count it owes accounted for as it goes.
32+pub struct LoudDump {
33+ /// Human-readable label for the failure line: the env var, or
34+ /// `VAR.suffix` when the file names something the var alone does not.
35+ site: String,
36+ path: PathBuf,
37+ file: Option<File>,
38+ written: usize,
39+ /// `None` only for a stream whose total length is genuinely unknowable at
40+ /// open time (an append-mode text table). Short-write detection still
41+ /// applies -- `write_all` reports a short write as `Err` -- but the failure
42+ /// line then carries no expected count, because inventing one would be a
43+ /// guess.
44+ expected: Option<usize>,
45+}
46+
47+impl LoudDump {
48+ /// Open `path` for `site`, expecting exactly `expected` bytes in total.
49+ ///
50+ /// Failing to CREATE is loud too: a requested dump that does not exist is
51+ /// the same silent hole as one that is short (the reader sees no file, or
52+ /// an empty one), and it is the more common of the two (a missing parent
53+ /// directory, a path a sweep reused as a directory).
54+ pub fn create(site: &str, path: impl AsRef<Path>, expected: usize) -> Self {
55+ let path = path.as_ref().to_path_buf();
56+ let file = File::create(&path).unwrap_or_else(|e| {
57+ abort(
58+ &site,
59+ &path,
60+ 0,
61+ Some(expected),
62+ &format!("could not create the dump file: {e}"),
63+ )
64+ });
65+ Self {
66+ site: site.to_string(),
67+ path,
68+ file: Some(file),
69+ written: 0,
70+ expected: Some(expected),
71+ }
72+ }
73+
74+ /// Open `path` for `site` in APPEND mode with no knowable total length --
75+ /// the CDF-table text dump, whose file spans every frame of a run. Write
76+ /// errors are still fatal; the length check is simply absent (see
77+ /// [`LoudDump::expected`]).
78+ pub fn append_unknown(site: &str, path: impl AsRef<Path>) -> Self {
79+ let path = path.as_ref().to_path_buf();
80+ let file = OpenOptions::new()
81+ .create(true)
82+ .append(true)
83+ .open(&path)
84+ .unwrap_or_else(|e| {
85+ abort(
86+ &site,
87+ &path,
88+ 0,
89+ None,
90+ &format!("could not open the dump file: {e}"),
91+ )
92+ });
93+ Self {
94+ site: site.to_string(),
95+ path,
96+ file: Some(file),
97+ written: 0,
98+ expected: None,
99+ }
100+ }
101+
102+ /// Hand `chunk` to the file. Overrunning `expected` is a caller bug (the
103+ /// count and the writer disagree) and aborts just as loudly as a short
104+ /// write, because one of the two is certainly lying.
105+ pub fn write(&mut self, chunk: &[u8]) {
106+ if let Some(exp) = self.expected
107+ && self.written + chunk.len() > exp
108+ {
109+ abort(
110+ &self.site,
111+ &self.path,
112+ self.written,
113+ Some(exp),
114+ &format!(
115+ "the writer was handed {} bytes but only {} remained of the {} it declared",
116+ chunk.len(),
117+ exp - self.written,
118+ exp
119+ ),
120+ );
121+ }
122+ let r = self.file.as_mut().expect("live dump").write_all(chunk);
123+ if let Err(e) = r {
124+ // MEASURED, do not assume: under `RLIMIT_FSIZE` the kernel stores
125+ // everything up to the cap and THEN returns `EFBIG` (measured:
126+ // a 49 152 B frame under caps of 4 KiB / 10 KiB / 30 KiB left
127+ // 4 096 / 10 240 / 30 720 B on disk, with `write_all` confirming
128+ // none of it). So "bytes written" on this line is the file's real
129+ // length, not the count `write_all` got to acknowledge -- the
130+ // acknowledged count rides along in the reason.
131+ let f = self.file.as_ref().expect("live dump");
132+ let on_disk = f
133+ .metadata()
134+ .map(|m| m.len() as usize)
135+ .unwrap_or(self.written);
136+ abort(
137+ &self.site,
138+ &self.path,
139+ on_disk,
140+ self.expected,
141+ &format!(
142+ "write failed with {} bytes confirmed in hand: {e}",
143+ self.written
144+ ),
145+ );
146+ }
147+ self.written += chunk.len();
148+ }
149+
150+ /// Close the dump: flush, then check the file's own length on disk.
151+ ///
152+ /// The on-disk check is not redundant with the write loop. `write_all`
153+ /// reports what the FILE ACCEPTED, and the reader's question is what the
154+ /// filesystem ended up holding -- a sparse/short final flush, a quota, or a
155+ /// filesystem-level reservation failure all land here rather than in
156+ /// `write`.
157+ pub fn finish(mut self) {
158+ let Some(mut file) = self.file.take() else { return };
159+ if let Err(e) = file.flush() {
160+ abort(
161+ &self.site,
162+ &self.path,
163+ self.written,
164+ self.expected,
165+ &format!("flush failed after {} bytes: {e}", self.written),
166+ );
167+ }
168+ let Some(exp) = self.expected else {
169+ return;
170+ };
171+ let on_disk = match file.metadata() {
172+ Ok(m) => m.len() as usize,
173+ Err(e) => abort(
174+ &self.site,
175+ &self.path,
176+ self.written,
177+ Some(exp),
178+ &format!("could not stat the finished dump: {e}"),
179+ ),
180+ };
181+ if on_disk != exp {
182+ abort(
183+ &self.site,
184+ &self.path,
185+ on_disk,
186+ Some(exp),
187+ "the file on disk is not the length the writer declared",
188+ );
189+ }
190+ }
191+}
192+
193+/// The single failure line every short dump now ends on. `site`, the path, the
194+/// bytes on disk vs the bytes owed, and the reason.
195+fn abort(site: &str, path: &Path, got: usize, expected: Option<usize>, why: &str) -> ! {
196+ let owed = match expected {
197+ Some(e) => format!("{e}"),
198+ None => "an unknown number of".to_string(),
199+ };
200+ panic!(
201+ "ec-av1 dump FAILED [{}] {}: wrote {} of {} bytes: {}",
202+ site,
203+ path.display(),
204+ got,
205+ owed,
206+ why
207+ );
208+}
209+
210+/// Write `planes` (already narrowed to their dump's sample width) as ONE dump
211+/// file, failing loudly on any shortfall. `expected` is the sum of the plane
212+/// lengths -- the same extents the writer iterates, so a plane that is shorter
213+/// than its geometry claims cannot hide here.
214+pub fn write_planes(site: &str, path: impl AsRef<Path>, planes: &[&[u8]]) {
215+ let expected: usize = planes.iter().map(|p| p.len()).sum();
216+ let mut d = LoudDump::create(site, path, expected);
217+ for p in planes {
218+ d.write(p);
219+ }
220+ d.finish();
221+}
222+
223+#[cfg(test)]
224+mod tests {
225+ use super::*;
226+ use std::process::Command;
227+
228+ fn scratch(tag: &str) -> PathBuf {
229+ let p = std::env::temp_dir().join(format!("ec-av1-dumpio-{tag}-{}", std::process::id()));
230+ let _ = std::fs::remove_file(&p);
231+ p
232+ }
233+
234+ fn caught(f: impl FnOnce() + std::panic::UnwindSafe) -> String {
235+ let prev = std::panic::take_hook();
236+ std::panic::set_hook(Box::new(|_| {}));
237+ let r = std::panic::catch_unwind(f);
238+ std::panic::set_hook(prev);
239+ let e = r.expect_err("the short dump must abort");
240+ e.downcast_ref::<String>()
241+ .cloned()
242+ .or_else(|| e.downcast_ref::<&str>().map(|s| (*s).to_string()))
243+ .expect("panic payload is a string")
244+ }
245+
246+ #[test]
247+ fn success_path_is_byte_identical_to_the_old_write_all_loop() {
248+ let p = scratch("ok");
249+ let planes: [&[u8]; 3] = [b"abc", b"", b"de"];
250+ write_planes("T", &p, &planes);
251+ assert_eq!(std::fs::read(&p).unwrap(), b"abcde");
252+ let _ = std::fs::remove_file(&p);
253+ }
254+
255+ /// `/dev/full` accepts an `open` for write and returns `ENOSPC` from every
256+ /// write -- the hermetic stand-in for the full filesystem that produced the
257+ /// 13 320 192-byte truncated frame in `lanes/unwritten-dep.report.md`.
258+ #[test]
259+ #[cfg(unix)]
260+ fn full_device_short_write_is_loud() {
261+ let msg = caught(|| write_planes("EC_AV1_FINAL_DUMP", "/dev/full", &[b"abc", b"de"]));
262+ assert!(
263+ msg.starts_with("ec-av1 dump FAILED [EC_AV1_FINAL_DUMP] /dev/full: wrote "),
264+ "{msg}"
265+ );
266+ assert!(msg.contains("No space left on device"), "{msg}");
267+ // The counts must be there, or the line does not say what was lost.
268+ assert!(msg.contains(" of 5 bytes"), "{msg}");
269+ }
270+
271+ #[test]
272+ fn uncreatable_dump_is_loud() {
273+ let p = std::env::temp_dir().join(format!("ec-av1-nodir-{}/x", std::process::id()));
274+ let msg = caught(|| write_planes("T", &p, &[b"abc"]));
275+ assert!(msg.contains("could not create the dump file"), "{msg}");
276+ }
277+
278+ /// A writer that under-declares its own expected length is the same silent
279+ /// hole: the reader gets a file the site believes is complete.
280+ #[test]
281+ fn under_declared_expected_length_is_loud() {
282+ let p = scratch("under");
283+ let msg = caught(|| {
284+ let mut d = LoudDump::create("T", &p, 2);
285+ d.write(b"abcdef");
286+ d.finish();
287+ });
288+ assert!(
289+ msg.contains("was handed 6 bytes but only 2 remained of the 2 it declared"),
290+ "{msg}"
291+ );
292+ let _ = std::fs::remove_file(&p);
293+ }
294+
295+ #[test]
296+ fn append_unknown_takes_no_length_claim() {
297+ let p = scratch("append");
298+ {
299+ let mut a = LoudDump::append_unknown("T", &p);
300+ a.write(b"x");
301+ a.finish();
302+ let mut b = LoudDump::append_unknown("T", &p);
303+ b.write(b"y");
304+ b.finish();
305+ }
306+ assert_eq!(std::fs::read(&p).unwrap(), b"xy");
307+ let msg = caught(|| {
308+ let mut a = LoudDump::append_unknown("T", "/dev/full");
309+ a.write(b"x");
310+ a.finish();
311+ });
312+ assert!(msg.contains("of an unknown number of bytes"), "{msg}");
313+ let _ = std::fs::remove_file(&p);
314+ }
315+ /// THE reproduction of the incident this module exists for: a real decode,
316+ /// a real `RLIMIT_FSIZE`, a real truncated `EC_AV1_FINAL_DUMP` file left
317+ /// on disk -- and the run stopping with the bytes-vs-bytes line instead of
318+ /// carrying on to a measurement built on the fragment.
319+ ///
320+ /// `/dev/full` (the unit test above) proves the writer's check works but
321+ /// never leaves a partial file behind, because `create` on it succeeds and
322+ /// nothing is ever stored. `RLIMIT_FSIZE` is the shape
323+ /// `lanes/unwritten-dep.report.md` actually measured: frames 0..4 complete
324+ /// plus 13 320 192 bytes of frame 5. `SIGXFSZ` is IGNORED (`trap "" XFSZ`)
325+ /// so the limit surfaces as `write`'s `EFBIG` -- exactly what a full
326+ /// filesystem's `ENOSPC` does -- instead of killing the child outright.
327+ #[test]
328+ #[cfg(unix)]
329+ fn a_real_decode_under_a_file_size_cap_fails_loudly() {
330+ let dir = std::env::temp_dir().join(format!("ec-av1-dumpio-cap-{}", std::process::id()));
331+ let _ = std::fs::remove_dir_all(&dir);
332+ std::fs::create_dir_all(&dir).unwrap();
333+ let prefix = dir.join("ours");
334+ // 8 blocks of 512 B = 4096 B: far below one 256x128 4:2:0 8-bit frame
335+ // (49 152 B), far above the file header, so the write lands and fails
336+ // PART way rather than at create.
337+ let out = Command::new("bash")
338+ .args([
339+ "-c",
340+ "ulimit -f 8; trap \"\" XFSZ; exec \"$0\" \"$@\"",
341+ // $0 for `bash -c` is the test binary itself.
342+ std::env::current_exe().unwrap().to_str().unwrap(),
343+ "--exact",
344+ "dumpio::tests::dumpio_child_decode",
345+ "--nocapture",
346+ ])
347+ .env("EC_AV1_DUMPLOUD_CHILD", "1")
348+ .env("EC_AV1_FINAL_DUMP", &prefix)
349+ // One thread, so the dump panic lands on the main thread and the
350+ // child's exit status is the decode's own.
351+ .env("EC_AV1_THREADS", "1")
352+ .output()
353+ .expect("spawning the capped child");
354+ let stderr = String::from_utf8_lossy(&out.stderr);
355+ assert!(
356+ !out.status.success(),
357+ "the decode must FAIL under a file-size cap, not finish with a truncated dump\n{stderr}"
358+ );
359+ assert!(
360+ stderr.contains("ec-av1 dump FAILED [EC_AV1_FINAL_DUMP]"),
361+ "the failure line must name the dump site\n{stderr}"
362+ );
363+ assert!(
364+ stderr.contains("File too large"),
365+ "the failure line must carry the OS error\n{stderr}"
366+ );
367+ // One 256x128 4:2:0 8-bit frame is 256*128*3/2 = 49 152 B, and the
368+ // failure line's "wrote N of 49152" must name the file's REAL length,
369+ // not the count `write_all` managed to acknowledge: a line that
370+ // under-reports is a line that sends the reader back to the dump to
371+ // measure it themselves.
372+ let frag = std::fs::metadata(format!("{}.f0", prefix.display()))
373+ .unwrap()
374+ .len();
375+ assert!(
376+ frag < 49152,
377+ "the capped child left a {frag}-byte frame where 49152 B was owed"
378+ );
379+ assert!(
380+ stderr.contains(&format!("wrote {frag} of 49152 bytes")),
381+ "the failure line's written count must be the file's actual length ({frag})\n{stderr}"
382+ );
383+ let _ = std::fs::remove_dir_all(&dir);
384+ }
385+
386+ /// Child half of [`a_real_decode_under_a_file_size_cap_fails_loudly`]. It is
387+ /// not a gate: with no `EC_AV1_DUMPLOUD_CHILD` guard it decodes nothing and
388+ /// asserts nothing, so a plain `cargo test` run is unaffected.
389+ #[test]
390+ fn dumpio_child_decode() {
391+ if std::env::var("EC_AV1_DUMPLOUD_CHILD").is_err() {
392+ return;
393+ }
394+ let path =
395+ std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/420_mixll_256x128_6f.obu");
396+ let bytes = std::fs::read(&path).expect("the pinned fixture");
397+ let _ = crate::stream::decode_stream(&bytes);
398+ }
399+}
crates/ec-av1/src/lib.rsmodified+1 -0
@@ -30,6 +30,7 @@ pub mod census;
30 mod compound;30 mod compound;
31 pub mod decode;31 pub mod decode;
32 pub mod encode;32 pub mod encode;
33+mod dumpio;
33 pub mod encoder;34 pub mod encoder;
34 mod envflags;35 mod envflags;
35 mod film_grain;36 mod film_grain;
crates/ec-av1/src/msac.rsmodified+27 -5
@@ -1004,7 +1004,9 @@ pub(crate) mod symtrace {
1004 thread_local! {1004 thread_local! {
1005 static BUF: RefCell<(String, usize)> = const { RefCell::new((String::new(), 0)) };1005 static BUF: RefCell<(String, usize)> = const { RefCell::new((String::new(), 0)) };
1006 static ECD: RefCell<VecDeque<(u32, u32, u32, u32)>> = RefCell::new(VecDeque::new());1006 static ECD: RefCell<VecDeque<(u32, u32, u32, u32)>> = RefCell::new(VecDeque::new());
1007- static ECD_READER: RefCell<Option<std::fs::File>> = const { RefCell::new(None) };1007+ // lane-av1dumploud: the file's PATH travels with it, so a short write
1008+ // can name the file it truncated instead of reconstructing a name.
1009+ static ECD_READER: RefCell<Option<(std::fs::File, String)>> = const { RefCell::new(None) };
1008 static ECD_IDX: RefCell<usize> = const { RefCell::new(0) };1010 static ECD_IDX: RefCell<usize> = const { RefCell::new(0) };
1009 }1011 }
1010 1012
@@ -1027,15 +1029,26 @@ pub(crate) mod symtrace {
1027 let _ = idx;1029 let _ = idx;
1028 let line = format!("{idx} ({low},{value},{rng},{bitpos})\n");1030 let line = format!("{idx} ({low},{value},{rng},{bitpos})\n");
1029 ECD_READER.with(|f| {1031 ECD_READER.with(|f| {
1032+ use std::io::Write;
1030 let mut slot = f.borrow_mut();1033 let mut slot = f.borrow_mut();
1031 if slot.is_none() {1034 if slot.is_none() {
1032 let seq = SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed);1035 let seq = SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
1033 let path = format!("{dir}/ecdump-{seq:05}.txt");1036 let path = format!("{dir}/ecdump-{seq:05}.txt");
1034- *slot = Some(std::fs::File::create(&path).expect("ecdump file"));
1035 eprintln!("ECDUMP -> {path}");1037 eprintln!("ECDUMP -> {path}");
1038+ *slot = Some((std::fs::File::create(&path).expect("ecdump file"), path));
1039+ }
1040+ // lane-av1dumploud: loud on a short write. This file is one line
1041+ // per symbol for a whole run, so its total length is unknowable at
1042+ // open time -- the failure line says "an unknown number of" rather
1043+ // than declaring a length it would have to invent.
1044+ let (file, path) = slot.as_mut().expect("just opened");
1045+ if let Err(e) = file.write_all(line.as_bytes()) {
1046+ panic!(
1047+ "ec-av1 dump FAILED [EC_AV1_ECDUMP] {path}: \
1048+ write failed after a partial line of {} bytes: {e}",
1049+ line.len()
1050+ );
1036 }1051 }
1037- use std::io::Write;
1038- let _ = slot.as_mut().unwrap().write_all(line.as_bytes());
1039 });1052 });
1040 ECD.with(|q| {1053 ECD.with(|q| {
1041 let mut q = q.borrow_mut();1054 let mut q = q.borrow_mut();
@@ -1119,8 +1132,17 @@ pub(crate) mod symtrace {
1119 BUF.with(|b| {1132 BUF.with(|b| {
1120 let (buf, n) = &mut *b.borrow_mut();1133 let (buf, n) = &mut *b.borrow_mut();
1121 if !buf.is_empty() {1134 if !buf.is_empty() {
1135+ // lane-av1dumploud: loud on a short write. `std::fs::write`
1136+ // returns a `Result` that this used to discard; the expected
1137+ // length is exactly the buffer's own.
1122 let seq = SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed);1138 let seq = SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
1123- let _ = std::fs::write(format!("{dir}/{side}-{seq:05}.txt"), buf.as_bytes());1139+ let (bytes, at) = (buf.as_bytes(), format!("{dir}/{side}-{seq:05}.txt"));
1140+ if let Err(e) = std::fs::write(&at, bytes) {
1141+ panic!(
1142+ "ec-av1 dump FAILED [EC_AV1_SYMTRACE] {at}: wrote 0 of {} bytes: {e}",
1143+ bytes.len()
1144+ );
1145+ }
1124 }1146 }
1125 buf.clear();1147 buf.clear();
1126 *n = 0;1148 *n = 0;
crates/ec-av1/src/stream.rsmodified+40 -30
@@ -2174,22 +2174,23 @@ fn decode_frame(
2174 // end-of-tile one.2174 // end-of-tile one.
2175 let stored_cdfs = stored_cdfs_for(header, end_cdfs, started_from);2175 let stored_cdfs = stored_cdfs_for(header, end_cdfs, started_from);
2176 if let Ok(path) = std::env::var("EC_AV1_DUMP_TABLES") {2176 if let Ok(path) = std::env::var("EC_AV1_DUMP_TABLES") {
2177- use std::io::Write;2177+ // lane-av1dumploud: loud on a short write. This one is APPEND-mode and
2178- if let Ok(mut f) = std::fs::OpenOptions::new()2178+ // spans every frame of a run, so there is no total length to declare
2179- .create(true)2179+ // (`append_unknown` says so on the failure line rather than guessing
2180- .append(true)2180+ // one); the per-line writes are still checked, so an ENOSPC halfway
2181- .open(&path)2181+ // through a table no longer passes as a complete one.
2182- {2182+ let mut f = crate::dumpio::LoudDump::append_unknown("EC_AV1_DUMP_TABLES", &path);
2183- let _ = writeln!(f, "=== frame idx={} ===", shown_idx);2183+ let mut line = |s: String| f.write(s.as_bytes());
2184- let _ = writeln!(f, "partition_w64 {:?}", stored_cdfs.partition_w64);2184+ line(format!("=== frame idx={shown_idx} ===\n"));
2185- let _ = writeln!(f, "partition_w32 {:?}", stored_cdfs.partition_w32);2185+ line(format!("partition_w64 {:?}\n", stored_cdfs.partition_w64));
2186- let _ = writeln!(f, "partition_w16 {:?}", stored_cdfs.partition_w16);2186+ line(format!("partition_w32 {:?}\n", stored_cdfs.partition_w32));
2187- let _ = writeln!(f, "skip {:?}", stored_cdfs.skip);2187+ line(format!("partition_w16 {:?}\n", stored_cdfs.partition_w16));
2188- let _ = writeln!(f, "new_mv {:?}", stored_cdfs.new_mv);2188+ line(format!("skip {:?}\n", stored_cdfs.skip));
2189- let _ = writeln!(f, "zero_mv {:?}", stored_cdfs.zero_mv);2189+ line(format!("new_mv {:?}\n", stored_cdfs.new_mv));
2190- let _ = writeln!(f, "ref_mv {:?}", stored_cdfs.ref_mv);2190+ line(format!("zero_mv {:?}\n", stored_cdfs.zero_mv));
2191- let _ = writeln!(f, "mv_joint {:?}", stored_cdfs.mv_joint);2191+ line(format!("ref_mv {:?}\n", stored_cdfs.ref_mv));
2192- }2192+ line(format!("mv_joint {:?}\n", stored_cdfs.mv_joint));
2193+ f.finish();
2193 }2194 }
2194 // lane-comppin r3: decode-order (not display-order) dump of every2195 // lane-comppin r3: decode-order (not display-order) dump of every
2195 // frame's own post-deblock buffer -- the pre-existing pixel diff2196 // frame's own post-deblock buffer -- the pre-existing pixel diff
@@ -2202,17 +2203,19 @@ fn decode_frame(
2202 // to isolate whether the defect is in a hidden frame's own2203 // to isolate whether the defect is in a hidden frame's own
2203 // reconstruction or downstream of it.2204 // reconstruction or downstream of it.
2204 if let Ok(path) = std::env::var("EC_AV1_DECODE_ORDER_DUMP") {2205 if let Ok(path) = std::env::var("EC_AV1_DECODE_ORDER_DUMP") {
2205- use std::io::Write;
2206- let idx = decode_idx;
2207- if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) {
2208 // lane-hbd r4: debug dump narrows to u8 -- this diagnostic2206 // lane-hbd r4: debug dump narrows to u8 -- this diagnostic
2209 // predates 10-bit support and is an 8-bit-oracle comparison2207 // predates 10-bit support and is an 8-bit-oracle comparison
2210 // only (aomdec's own dump is 8-bit here too).2208 // only (aomdec's own dump is 8-bit here too).
2209+ //
2210+ // lane-av1dumploud: loud on a short write; expected length is the three
2211+ // planes' own lengths (narrowing is 1 byte per sample, so the count is
2212+ // unchanged).
2211 let narrow = |v: &[u16]| -> Vec<u8> { v.iter().map(|&s| s as u8).collect() };2213 let narrow = |v: &[u16]| -> Vec<u8> { v.iter().map(|&s| s as u8).collect() };
2212- let _ = f.write_all(&narrow(&picture.y));2214+ crate::dumpio::write_planes(
2213- let _ = f.write_all(&narrow(&picture.u));2215+ "EC_AV1_DECODE_ORDER_DUMP",
2214- let _ = f.write_all(&narrow(&picture.v));2216+ format!("{path}.f{decode_idx}"),
2215- }2217+ &[&narrow(&picture.y), &narrow(&picture.u), &narrow(&picture.v)],
2218+ );
2216 }2219 }
2217 // lane-hidden r1: the frame exactly as it is about to be stored into2220 // lane-hidden r1: the frame exactly as it is about to be stored into
2218 // the reference slots -- after deblock/CDEF/LR/superres, in DECODE2221 // the reference slots -- after deblock/CDEF/LR/superres, in DECODE
@@ -2247,20 +2250,27 @@ fn decode_frame(
2247 // stores and every later frame predicts from.2250 // stores and every later frame predicts from.
2248 decode::census_unwritten_final(&picture.y, &picture.u, &picture.v);2251 decode::census_unwritten_final(&picture.y, &picture.u, &picture.v);
2249 if let Some(prefix) = final_dump {2252 if let Some(prefix) = final_dump {
2250- use std::io::Write;2253+ // lane-av1dumploud: this is the site that produced the 13 320 192-byte
2251- if let Ok(mut f) = std::fs::File::create(format!("{prefix}.f{decode_idx}")) {2254+ // truncated frame in `lanes/unwritten-dep.report.md` -- `let _ =
2252- let mut buf = Vec::new();2255+ // f.write_all(&buf)` swallowed the ENOSPC. Expected length is derived
2256+ // from the PLANES and the sample width, independently of `buf`, so a
2257+ // writer that builds the wrong buffer still gets caught.
2258+ let sample_width = if bit_depth == 8 { 1 } else { 2 };
2259+ let expected = (picture.y.len() + picture.u.len() + picture.v.len()) * sample_width;
2260+ let mut f =
2261+ crate::dumpio::LoudDump::create("EC_AV1_FINAL_DUMP", format!("{prefix}.f{decode_idx}"), expected);
2253 for plane in [&picture.y, &picture.u, &picture.v] {2262 for plane in [&picture.y, &picture.u, &picture.v] {
2254 if bit_depth == 8 {2263 if bit_depth == 8 {
2255- buf.extend(plane.iter().map(|&s| s as u8));2264+ f.write(&plane.iter().map(|&s| s as u8).collect::<Vec<u8>>());
2256 } else {2265 } else {
2266+ let mut row = Vec::with_capacity(plane.len() * 2);
2257 for &s in plane {2267 for &s in plane {
2258- buf.extend_from_slice(&s.to_le_bytes());2268+ row.extend_from_slice(&s.to_le_bytes());
2259- }
2260 }2269 }
2270+ f.write(&row);
2261 }2271 }
2262- let _ = f.write_all(&buf);
2263 }2272 }
2273+ f.finish();
2264 }2274 }
2265 Ok(FrameOutput {2275 Ok(FrameOutput {
2266 picture,2276 picture,
lanes/av1dumploud.report.mdadded+284 -0
@@ -0,0 +1,284 @@
1+# lane/av1dumploud — every dump site fails loudly on a short write
2+
3+**Outcome in one line:** all 11 dump write sites in `crates/ec-av1` now account
4+for their own byte count and abort the run with the file, the bytes on disk, the
5+bytes owed and the OS error; one real decode under a real `RLIMIT_FSIZE` is
6+reproduced as a FAILING run; the `reelb_rect64_intra16x4_witness` hash sweep is
7+byte-identical to `lanes/unwritten-dep.report.md` §2 with the loud writer in
8+place; the campaign value `0ee1edf403` is **still not reproduced** and stays open
9+with the mechanism class now provably closed going forward.
10+
11+Base: `f01e9738`. Branch: `lane/av1dumploud`. Worktree:
12+`/home/user/.cache/wt/av1dumploud`. Target dir:
13+`/home/user/.cache/target-av1dumploud`.
14+
15+The class this lane closes is named in `lanes/unwritten-dep.report.md` §9 as an
16+open item: *"The dump sites still swallow their write errors, so a short dump
17+remains possible — the artefact behind §3."* That is now closed for every site.
18+
19+---
20+
21+## 1. Every dump write site, and what a FULL write means for it
22+
23+New module: `crates/ec-av1/src/dumpio.rs`. `LoudDump::create(site, path,
24+expected)` opens the file, `write(chunk)` hands it bytes, `finish()` flushes and
25+then compares the file's **own length on disk** against `expected`. Any shortfall,
26+and any failure to create the file at all, panics with one fixed line:
27+
28+```text
29+ec-av1 dump FAILED [<site>] <path>: wrote <on-disk bytes> of <owed> bytes: <reason>
30+```
31+
32+| # | Site (file:fn) | Env var | File | Dump shape | FULL write = |
33+|---|---|---|---|---|---|
34+| 1 | `decode.rs:21147` `dump_stage16` | `EC_AV1_PREFILT_DUMP16`, `EC_AV1_POSTDEBLOCK_DUMP16`, `EC_AV1_POSTCDEF_DUMP16` | `<prefix>.f<N>` | 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 |
35+| 2 | `decode.rs:21235` `dump_stage` | `EC_AV1_POSTDEBLOCK_DUMP`, `EC_AV1_POSTCDEF_DUMP` | `<prefix>.f<N>` | whole padded plane, u8 | `y.data.len() + u.data.len() + v.data.len()` |
36+| 3 | `decode.rs:21259` `dump_prefilter_wide` | `EC_AV1_PREFILT_WIDE_DUMP` | `<prefix>.f<N>` | mi-aligned crop, u8 | `Σ true_width * true_height` over the three planes |
37+| 4 | `decode.rs:38237` (key-frame twin) | `EC_AV1_PREFILT_DUMP` | `<prefix>.f<N>` | whole padded plane, u8 | `Σ p.data.len()` |
38+| 5 | `decode.rs:56608` (inter-frame twin) | `EC_AV1_PREFILT_DUMP` | `<prefix>.f<N>` | whole padded plane, u8 | `Σ p.data.len()` |
39+| 6 | `decode.rs:38471` margin dump | `EC_AV1_MARGIN_DUMP` | `<prefix>.f<N>` | `true_width x true_height` luma crop, u8 | `true_width * true_height` |
40+| 7 | `stream.rs:2205` | `EC_AV1_DECODE_ORDER_DUMP` | `<prefix>.f<N>` | post-deblock, u8-narrowed | `y.len() + u.len() + v.len()` (narrowing is 1 B/sample) |
41+| 8 | `stream.rs:2252` | `EC_AV1_FINAL_DUMP` | `<prefix>.f<N>` | 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 |
42+| 9 | `stream.rs:2176` | `EC_AV1_DUMP_TABLES` | `<path>` (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. |
43+| 10 | `msac.rs:1031` `symtrace::ecdump` | `EC_AV1_ECDUMP` | `<dir>/ecdump-<n>.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). |
44+| 11 | `msac.rs:1130` `symtrace::flush` | symtrace dir | `<dir>/<side>-<n>.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. |
45+
46+**Row 11 is the one site verified by `Result` alone.** `std::fs::write` returns
47+only a `Result`, so unlike the other ten there is no handle to keep, no
48+`finish()`, and no second look at the file's own length on disk. It is still
49+loud on a short write — `Err` is fatal — but its check is the `Result` and
50+nothing more. Do not read the table's "FULL write" column as identical
51+verification for all eleven: rows 1–10 are checked twice (bytes handed in, then
52+the file on disk), row 11 once.
53+
54+**Out of scope, named rather than skipped.** Three shapes:
55+
56+* **Nine `#[cfg(test)]` stream-pin sites** — `stream.rs` ≈ 14191, 18201, 23170,
57+ 23190, 23589, 23611, 27904, 28896, 29106. Each does `let _ = std::fs::write(
58+ &pin, &stream)` and then `panic!`s on the next line naming the pin. **A
59+ truncated pin is a live residue here, and it is not fixed by this lane**: the
60+ write result is discarded, so an `ENOSPC` or an `RLIMIT_FSIZE` hit partway
61+ through a multi-megabyte `.obu` leaves a SHORT stream at exactly the path the
62+ following `panic!` hands the reader ("stream pinned at {}"). "No decode
63+ measurement is built on the file" is true of the test's VERDICT — which comes
64+ from the assert, not the artefact — and is not true of the artefact. Named, not
65+ fixed: these are test-side pins, and making them loud would change what a
66+ failing gate prints rather than what a failing gate decides.
67+* **`stream.rs:28143`**, the tenth pin site and a different shape: it checks the
68+ `Result`, but **warns and continues** — `eprintln!("cdfflake: could not pin to
69+ {}: {e}", …)` — by explicit design, because its own comment says a failed
70+ write must not mask the assert below it. So neither the "they panic on the next
71+ line" reason above nor the "discards the result" one applies to it. It is
72+ excluded on the same ground as the nine (a `#[cfg(test)]` pin whose verdict
73+ comes from the assert), with the extra note that its own failure path is
74+ already deliberate and non-fatal.
75+* **`probe.rs:158`**: a stdin pipe to a child process, swallowed on purpose so
76+ the child's own exit status and stderr carry the diagnosis (the documented
77+ `aomenc-stdin` deadlock fix). Not a file at all.
78+
79+### Success path
80+
81+Byte-identical, by construction: same bytes, same order, same file names, same
82+per-var index (`dump_stage_idx` is still only called when the var is set, and
83+still once per frame). `dumpio::tests::success_path_is_byte_identical_to_the_old_write_all_loop`
84+pins the three-plane concatenation, and §4's sweep pins the real geometry: every
85+frame of both 10-bit witnesses is exactly 18 524 160 B, unchanged.
86+
87+### The one behaviour change visible without a disk error
88+
89+**A dump that cannot be CREATED is now fatal too** (missing parent directory, a
90+path a sweep reused as a directory). It is the same silent hole as a short dump
91+— the reader sees no file, or an empty one — and it is the more common of the
92+two. This only fires when the operator has explicitly set the env var.
93+
94+---
95+
96+## 2. The reproduced short write
97+
98+`RLIMIT_FSIZE` is the shape `lanes/unwritten-dep.report.md` §3 actually measured
99+(frames 0..4 complete plus 13 320 192 B of frame 5). `SIGXFSZ` is **ignored**
100+(`trap "" XFSZ`) so the limit surfaces as `write`'s `EFBIG` — exactly what a full
101+filesystem's `ENOSPC` does — instead of killing the child. Committed gate:
102+`dumpio::tests::a_real_decode_under_a_file_size_cap_fails_loudly`, which drives a
103+real decode of the pinned `420_mixll_256x128_6f.obu` in a child process under a
104+4 KiB cap and asserts the run FAILS.
105+
106+Captured output (same child, three caps; one 256×128 4:2:0 8-bit frame owes
107+49 152 B):
108+
109+```
110+=== ulimit -f 8 (4096 B) ===
111+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)
112+child exit=101 ours.f0 = 4096 B
113+
114+=== ulimit -f 20 (10240 B) ===
115+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)
116+child exit=101 ours.f0 = 10240 B
117+
118+=== ulimit -f 60 (30720 B) ===
119+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)
120+child exit=101 ours.f0 = 30720 B
121+
122+=== uncapped ===
123+child exit=0 ours.f0 … ours.f6 = 49152 B each
124+```
125+
126+Two things this measurement corrected, and would have got wrong by assumption:
127+
128+1. **The kernel stores up to the cap and THEN returns `EFBIG`** — `write_all`
129+ confirms *none* of it. The naive "bytes acknowledged" count would have printed
130+ `wrote 0` while 30 720 B sat on disk. The failure line therefore reports the
131+ file's **measured length on disk**, and carries the acknowledged count
132+ separately ("0 bytes confirmed in hand"). The gate asserts the reported number
133+ EQUALS the fragment's real length, so the line cannot drift from the artefact.
134+2. The empty-file variant of the incident ("an empty dump read as
135+ instability") is the `wrote 0` end of the same sweep, not a separate case.
136+
137+Supporting gates (`crates/ec-av1/src/dumpio.rs`): `/dev/full` (hermetic `ENOSPC`,
138+no bytes stored), an uncreatable path, a writer that under-declares its own
139+expected length, and the append-unknown case asserting the "unknown number of"
140+wording.
141+
142+---
143+
144+## 3. `0ee1edf403` — still not reproduced, and now bounded
145+
146+Re-attempted on `reelb_rect64_intra16x4_witness.obu` (23 472 B, sha256
147+`c9e721088766163b…`) with the loud writer in place.
148+
149+```text
150+--- A. plain, 3 processes ---
151+ rc=0 sha=a26438168c3c53a0 frames=34 ×3, identical
152+--- B. sentinel (EC_AV1_PLANE_SENTINEL=1), 3 processes ---
153+ rc=0 sha=a26438168c3c53a0 frames=34 ×3, identical
154+--- C. two decodes CONCURRENTLY into one reused directory ---
155+ rc=0/0 sha=a26438168c3c53a0 frames=34
156+--- D. RLIMIT_FSIZE sweep ---
157+ cap=32768B rc=101 wrote 65536 of 18524160 bytes sha=2d3745b17d665bed frames=1
158+ cap=65536B rc=101 wrote 131072 of 18524160 bytes sha=1fd52689ef20fb22 frames=1
159+ cap=262144B rc=101 wrote 524288 of 18524160 bytes sha=5d13ba5d22458efb frames=1
160+ cap=1048576B rc=101 wrote 2097152 of 18524160 bytes sha=5f745dcff3520f78 frames=1
161+ cap=2097152B rc=101 wrote 4194304 of 18524160 bytes sha=0aafa68194719c7c frames=1
162+ cap=4194304B rc=101 wrote 8388608 of 18524160 bytes sha=7cab950993a6fcc7 frames=1
163+ cap=8388608B rc=101 wrote 16777216 of 18524160 bytes:
164+ write failed with 15436800 bytes confirmed in hand
165+ sha=1bf8cc62449548a5 frames=1
166+ cap=16777216B rc=0 <no loud failure> sha=a26438168c3c53a0 frames=34
167+--- E. truncated-prefix arithmetic sweep ---
168+ 34 frames of 18524160 B, full stream 629821440 B
169+ shapes checked: whole stream + 34 whole-frame prefixes
170+ + 34 × {1/4, 1/512, 1/1024, 1/4096, 1/65536} partial cuts → matches: 0
171+```
172+
173+**What the new evidence RULES OUT (mechanism class, not the value):** any dump
174+truncated by a filesystem-full, quota or `RLIMIT_FSIZE` failure. Seven caps were
175+swept; every truncating one now ABORTS with the bytes-vs-expected line instead of
176+leaving an artefact, and none of the seven artefacts that did get written on the
177+way down hashes to `0ee1edf403`. The `cap=8388608B` row is the campaign's own
178+reported shape — complete frames plus a partial tail — now with the confirmed
179+prefix count in the line. The concurrent-reuse shape is likewise closed here:
180+both processes exited 0 with every frame at full length.
181+
182+**What it does NOT rule out, stated plainly:**
183+
184+* **A killed process.** `SIGKILL`/`SIGTERM` between two frame writes runs no code,
185+ so no failure line can be emitted and the artefact is exactly the prefix. The
186+ loud writer cannot see this; nothing in this lane can. A timeout-killed campaign
187+ run remains a live explanation.
188+* **A different build or host.** `0ee1edf403` never reproduced on *any* tree
189+ measured, plain or sentinel; the campaign's own PLAIN value reproduces here,
190+ which means the divergence was already present in its plain runs too.
191+* **The value itself.** `0ee1edf403` remains an unreproduced 10-hex artefact
192+ after 34 whole-frame prefixes, 170 partial cuts, 3 plain and 3 sentinel
193+ processes, and a concurrent reuse. **Not closed, and not closed by assertion.**
194+
195+**Disposition: OPEN (instrument hygiene).** The decode remains invariant — plain
196+and sentinel agree, 3/3 and 3/3, in 34 frames of exactly 18 524 160 B — so nothing
197+here makes it a decoder defect. What changed is that one whole family of
198+explanations (silent truncation) is now closed at the instrument, so the next
199+attempt does not have to re-sweep it.
200+
201+---
202+
203+## 4. The sweep whose hashes must not move
204+
205+`reelb_rect64_intra16x4_witness` and `reelb_arf_witness`, one decode per PROCESS,
206+decode-order `cat frame.f*` hashed, every frame's size read back:
207+
208+```text
209+reelb_rect64_intra16x4_witness run1 rc=0 frames=34 sizes=[18524160] sha=a26438168c3c53a0
210+reelb_rect64_intra16x4_witness run2 rc=0 frames=34 sizes=[18524160] sha=a26438168c3c53a0
211+reelb_rect64_intra16x4_witness run3 rc=0 frames=34 sizes=[18524160] sha=a26438168c3c53a0
212+reelb_arf_witness run1 rc=0 frames=40 sizes=[18524160] sha=8d7a43bc5fcf840a
213+reelb_arf_witness run2 rc=0 frames=40 sizes=[18524160] sha=8d7a43bc5fcf840a
214+reelb_arf_witness run3 rc=0 frames=40 sizes=[18524160] sha=8d7a43bc5fcf840a
215+```
216+
217+Against `lanes/unwritten-dep.report.md` §2: `a26438168c` and `8d7a43bc5f` —
218+**unchanged, prefix for prefix, with the loud writer in place.** The frame size
219+18524160 is the one §2/§10 assert by hand; it is now asserted by the writer on
220+every single frame, so a sweep can no longer "pass" a short one.
221+
222+---
223+
224+## 5. Gates run
225+
226+```
227+cargo test -p ec-av1 --lib -- dump
228+ dumpio::tests::a_real_decode_under_a_file_size_cap_fails_loudly ... ok
229+ dumpio::tests::full_device_short_write_is_loud ... ok
230+ dumpio::tests::success_path_is_byte_identical_to_the_old_write_all_loop ... ok
231+ dumpio::tests::append_unknown_takes_no_length_claim ... ok
232+ dumpio::tests::uncreatable_dump_is_loud ... ok
233+ dumpio::tests::under_declared_expected_length_is_loud ... ok
234+ stream::tests::pinned_lr_sgr_stream_call_unique_dump ... ok
235+ wedge::tests::wedge_codebook_matches_libaom_dump ... ok
236+ intra::tests::rect_predictors_match_c_dump ... ok
237+ test result: ok. 10 passed; 0 failed; 0 ignored
238+```
239+cargo test -p ec-av1 --lib -- the_frame_the_caller_receives_carries_no_unwritten_plane_sample
240+ test result: ok. 1 passed; 0 failed (71 s)
241+```
242+
243+`dumpio::tests::dumpio_child_decode` is the child half of the RLIMIT gate. It is
244+not a gate: with no `EC_AV1_DUMPLOUD_CHILD` guard it decodes nothing and asserts
245+nothing, so a plain `cargo test` run is unaffected.
246+
247+Full-crate validation is Main's job and was not run here (sibling lanes are
248+editing concurrently).
249+
250+---
251+
252+## 6. What this lane did not do
253+
254+* Did not close `0ee1edf403`. See §3 for what is and is not ruled out.
255+* Did not touch the reserved 4:2:0 group-tail chroma SKIP arm, `film_grain.rs`,
256+ or any decode semantics. The only behavioural changes are: a dump that cannot
257+ be written now ends the run, and a dump that cannot be created now ends the run.
258+* Did not change what any dump CONTAINS, or its file naming or index.
259+* Did not add `dumpio` to the public API (`mod dumpio`, private) — it is an
260+ instrument, not a surface.
261+* Did not sweep the pinned `440_request_is_422` cell: `main` = `f01e9738`
262+ refuses it, same as `e45cc748` did in §10.
263+* **Did not make the ten `#[cfg(test)]` stream pins loud** (§1, "Out of
264+ scope"). A short write to one of them leaves a truncated `.obu` at exactly the
265+ path the following `panic!` hands the reader. Named residue, deliberately not
266+ fixed here: these are test-side pins whose verdict comes from the assert, not
267+ from the file, and the one site that already handles its own failure
268+ (`stream.rs:28143`) does so by design. If a lane wants them closed, the shape
269+ is `LoudDump::create(site, path, stream.len())` — the same three lines as the
270+ eleven — but it is a change to what a FAILING GATE PRINTS, and that is a
271+ decision for the owner of the gates, not for an instrument lane.
272+
273+## 7. Coordination
274+
275+Peer lane `av1uballoc` owns `fresh_plane` in `decode.rs` (~21820–21860, the
276+`plane_sentinel_on()` allocation path). Untouched by this lane.
277+
278+Lines this lane changed in `crates/ec-av1/src/decode.rs`: **21156–21215**
279+(`dump_stage16`), **21217–21250** (`dump_stage`), **21250–21284**
280+(`dump_prefilter_wide`), **38237–38252** (key-frame `EC_AV1_PREFILT_DUMP`),
281+**38471–38488** (`EC_AV1_MARGIN_DUMP`), **56608–56623** (inter-frame
282+`EC_AV1_PREFILT_DUMP`). Plus `stream.rs` 2176–2194, 2205–2219, 2252–2274;
283+`msac.rs` 1007–1009, 1031–1052, 1135–1146; `lib.rs` 33; new file
284+`src/dumpio.rs`.
\ No newline at end of file\ No newline at end of file