From 2d08a6d2eae8b5be2c700dcfd74330410e325e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 2 Oct 2026 02:39:00 +0300 Subject: [PATCH] ec-av1 r2: label the pin site TEST_PIN, correct the pin/pin_reporting doc split, amend the sweep rows - the pin site label moves out of the EC_AV1_* env-var namespace (no env var of that name exists; EC_AV1_PIN is the scratch replay helper's) so a triager grepping the failure line is not sent to the wrong thing - pin_reporting re-implements the length check rather than wrapping LoudDump (whose failure channel is panic!); say so where a reader would assume otherwise - the h264/h265 rows are half-open, not closed: fs::write returning Ok does not guarantee the on-disk length --- crates/ec-av1/src/dumpio.rs | 43 ++++++++++++++++------------ crates/ec-av1/src/stream.rs | 20 ++++++------- lanes/av1pinloud.report.md | 56 ++++++++++++++++++++++++------------- 3 files changed, 72 insertions(+), 47 deletions(-) diff --git a/crates/ec-av1/src/dumpio.rs b/crates/ec-av1/src/dumpio.rs index eb44bb2e..dd3afd6f 100644 --- a/crates/ec-av1/src/dumpio.rs +++ b/crates/ec-av1/src/dumpio.rs @@ -215,8 +215,9 @@ fn failure_line(site: &str, path: &Path, got: usize, expected: Option, wh ) } -/// Write `bytes` to `path` as a FATAL pin, loud on any shortfall -- [`pin`]'s -/// counterpart to [`write_planes`], for the single-blob case. +/// Write `bytes` to `path` as a FATAL pin: [`pin`] IS a wrapper -- three +/// [`LoudDump`] calls (`create`/`write`/`finish`), so it inherits the flush and +/// the flush-then-stat ordering for free. /// /// lane-av1pinloud: the test-pin sites in `stream.rs` wrote with /// `let _ = std::fs::write(..)` and then named the path in the panic that @@ -230,11 +231,20 @@ pub fn pin(site: &str, path: impl AsRef, bytes: &[u8]) { d.finish(); } -/// [`pin`] for a site that must NOT die on a failed pin -- a gate whose real -/// failure is the assert that comes after the pin attempt, and whose comment -/// says so. Non-fatal, but not silent: a shortfall comes back as the very same -/// failure line [`pin`] would have panicked with, expected-vs-on-disk counts -/// included, for the caller to print as a warning. +/// [`pin`]'s NON-FATAL twin, for a site that must not die on a failed pin -- a +/// gate whose real failure is the assert that comes after the pin attempt, and +/// whose comment says so. +/// +/// This one RE-IMPLEMENTS the check rather than wrapping [`LoudDump`], whose +/// failure channel is `panic!`: it cannot report instead of dying. So it does +/// `fs::write` + `metadata` itself. Only the failure LINE is shared, via +/// [`failure_line`] -- the ordering (flush-then-stat) and the +/// write-error-handling are not shared with [`LoudDump`], and a reader must not +/// assume they are. +/// +/// Non-fatal, but not silent: a shortfall comes back as the very same failure +/// line [`pin`] would have panicked with, expected-vs-on-disk counts included, +/// for the caller to print as a warning. pub fn pin_reporting(site: &str, path: impl AsRef, bytes: &[u8]) -> Result<(), String> { let path = path.as_ref(); let expected = bytes.len(); @@ -467,7 +477,7 @@ mod tests { #[test] fn pin_success_path_is_byte_identical() { let p = scratch("pin-ok"); - pin("EC_AV1_PIN", &p, b"stream bytes"); + pin("TEST_PIN", &p, b"stream bytes"); assert_eq!(std::fs::read(&p).unwrap(), b"stream bytes"); let _ = std::fs::remove_file(&p); } @@ -475,9 +485,9 @@ mod tests { #[test] #[cfg(unix)] fn pin_to_a_full_device_is_loud() { - let msg = caught(|| pin("EC_AV1_PIN", "/dev/full", b"stream bytes")); + let msg = caught(|| pin("TEST_PIN", "/dev/full", b"stream bytes")); assert!( - msg.starts_with("ec-av1 dump FAILED [EC_AV1_PIN] /dev/full: wrote "), + msg.starts_with("ec-av1 dump FAILED [TEST_PIN] /dev/full: wrote "), "{msg}" ); assert!(msg.contains("No space left on device"), "{msg}"); @@ -490,14 +500,14 @@ mod tests { #[test] #[cfg(unix)] fn pin_reporting_is_loud_but_not_fatal() { - let line = pin_reporting("EC_AV1_PIN", "/dev/full", b"stream bytes").unwrap_err(); + let line = pin_reporting("TEST_PIN", "/dev/full", b"stream bytes").unwrap_err(); assert!( - line.contains("ec-av1 dump FAILED [EC_AV1_PIN] /dev/full"), + line.contains("ec-av1 dump FAILED [TEST_PIN] /dev/full"), "{line}" ); assert!(line.contains(" of 12 bytes"), "{line}"); let p = scratch("pin-reporting-ok"); - pin_reporting("EC_AV1_PIN", &p, b"stream bytes").expect("a healthy pin reports nothing"); + pin_reporting("TEST_PIN", &p, b"stream bytes").expect("a healthy pin reports nothing"); assert_eq!(std::fs::read(&p).unwrap(), b"stream bytes"); let _ = std::fs::remove_file(&p); } @@ -525,10 +535,7 @@ mod tests { .expect("spawning the capped child"); let stderr = String::from_utf8_lossy(&out.stderr); assert!(!out.status.success(), "a short pin must fail\n{stderr}"); - assert!( - stderr.contains("ec-av1 dump FAILED [EC_AV1_PIN]"), - "{stderr}" - ); + assert!(stderr.contains("ec-av1 dump FAILED [TEST_PIN]"), "{stderr}"); assert!(stderr.contains("File too large"), "{stderr}"); let frag = std::fs::metadata(dir.join("cap-pinned.obu")).unwrap().len(); assert!( @@ -552,7 +559,7 @@ mod tests { // `ulimit -f 8` is 8 KiB, so 4x that is guaranteed to run PAST the cap // (a write of exactly the cap size succeeds) and land a fragment. pin( - "EC_AV1_PIN", + "TEST_PIN", Path::new(&dir).join("cap-pinned.obu"), &[7u8; 32768], ); diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 04f230dc..c1cd47be 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -14195,7 +14195,7 @@ exit 0 assert_eq!(a.len(), b.len(), "{name}: frame {i} {plane} plane length"); if a != b { let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); + crate::dumpio::pin("TEST_PIN", &pin, &stream); let at = a .iter() .zip(b.iter()) @@ -18205,7 +18205,7 @@ exit 0 for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { if got.y != want.y || got.u != want.u || got.v != want.v { let pin = std::env::temp_dir().join("ec-av1-10bit-inter-gate-fail.obu"); - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); + crate::dumpio::pin("TEST_PIN", &pin, &stream); let first = |a: &Vec, b: &Vec| { a.iter() .zip(b) @@ -23174,7 +23174,7 @@ exit 0 Ok(frames) => frames, Err(e) => { let pin = std::env::temp_dir().join(format!("{name}-refused.obu")); - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); + crate::dumpio::pin("TEST_PIN", &pin, &stream); panic!( "{name}: decode_stream refused a real aomenc stream: {e} (pinned at {})", pin.display() @@ -23194,7 +23194,7 @@ exit 0 for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { if got.y != want.y || got.u != want.u || got.v != want.v { let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); + crate::dumpio::pin("TEST_PIN", &pin, &stream); panic!( "{name}: frame {i} mismatch vs ffmpeg -- stream pinned at {}", pin.display() @@ -23593,7 +23593,7 @@ exit 0 } Err(e) => { let pin = std::env::temp_dir().join(format!("{name}-refused.obu")); - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); + crate::dumpio::pin("TEST_PIN", &pin, &stream); panic!( "{name}: decode_stream failed on a real aomenc stream (cq={cq} period={period}): {e} (pinned at {})", pin.display() @@ -23615,7 +23615,7 @@ exit 0 for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { if got.y != want.y || got.u != want.u || got.v != want.v { let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); + crate::dumpio::pin("TEST_PIN", &pin, &stream); panic!( "{name}: frame {i} mismatch vs ffmpeg (cq={cq} period={period}) -- stream pinned at {}", pin.display() @@ -27908,7 +27908,7 @@ exit 0 "ec-av1-deblocking-gate-fail-s{}-cq{cq}.obu", 42 + round )); - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); + crate::dumpio::pin("TEST_PIN", &pin, &stream); panic!( "frame {i} mismatch vs ffmpeg (seed {} cq {cq}, deblock fired: \ {counted}) -- stream pinned at {}", @@ -28151,7 +28151,7 @@ exit 0 let stream_pin = sp.join(format!("cdfflake-stream-seed{seed}.bin")); let ref_pin = sp.join(format!("cdfflake-ffmpeg-raw-seed{seed}.bin")); for (path, bytes) in [(&stream_pin, &stream), (&ref_pin, &ffmpeg_raw)] { - if let Err(line) = crate::dumpio::pin_reporting("EC_AV1_PIN", path, bytes) { + if let Err(line) = crate::dumpio::pin_reporting("TEST_PIN", path, bytes) { eprintln!("cdfflake: {line}"); } } @@ -28904,7 +28904,7 @@ exit 0 if mismatched { let pin = std::env::temp_dir().join("ec-av1-reference-select-gate-fail.obu"); - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); + crate::dumpio::pin("TEST_PIN", &pin, &stream); if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { crate::dumpio::pin("EC_AV1_GATE_DUMP", &path, &stream); eprintln!( @@ -29114,7 +29114,7 @@ exit 0 .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); if mismatched { let pin = std::env::temp_dir().join("ec-av1-compound-refs-gate-fail.obu"); - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); + crate::dumpio::pin("TEST_PIN", &pin, &stream); if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { crate::dumpio::pin("EC_AV1_GATE_DUMP", &path, &stream); eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); diff --git a/lanes/av1pinloud.report.md b/lanes/av1pinloud.report.md index 28942af7..b288917d 100644 --- a/lanes/av1pinloud.report.md +++ b/lanes/av1pinloud.report.md @@ -22,8 +22,8 @@ length. ## Change -`crates/ec-av1/src/dumpio.rs` gains two wrappers over the existing `LoudDump`, plus a -`failure_line` helper so the fatal and reporting shapes cannot drift: +`crates/ec-av1/src/dumpio.rs` gains two pin helpers plus a `failure_line` helper so the +fatal and reporting message shapes cannot drift: - `pin(site, path, bytes)` — fatal. Same shape as `write_planes` for a single blob: create, `write_all`, then stat the file and compare against `bytes.len()`. @@ -31,32 +31,49 @@ length. truncate-then-write. - `pin_reporting(site, path, bytes) -> Result<(), String>` — non-fatal, not silent. Returns the **same** failure line `pin` would have panicked with - (`ec-av1 dump FAILED [EC_AV1_PIN] : wrote N of M bytes: `). + (`ec-av1 dump FAILED [TEST_PIN] : wrote N of M bytes: `). -All nine pin sites now call `pin("EC_AV1_PIN", ...)`; both `EC_AV1_GATE_DUMP` writes -call `pin("EC_AV1_GATE_DUMP", ...)` (previously `fs::write(...).expect(...)`, loud on a -write error but blind to a short file on disk). +These are NOT both wrappers over `LoudDump`, and the difference is load-bearing: + +- `pin` **is** a wrapper — three `LoudDump` calls (`create`/`write`/`finish`), so it + inherits the flush and the flush-then-stat ordering for free. +- `pin_reporting` **re-implements** the check with `fs::write` + `metadata`, because + `LoudDump`'s failure channel is `panic!` and this site must not die. Only the failure + *line* is shared (via `failure_line`); the ordering is not. + +All nine pin sites now call `pin("TEST_PIN", ...)`; both `EC_AV1_GATE_DUMP` writes call +`pin("EC_AV1_GATE_DUMP", ...)` (previously `fs::write(...).expect(...)`, loud on a write +error but blind to a short file on disk). One more in-crate site of the same shape: `msac.rs:1140` (`EC_AV1_SYMTRACE` flush) had a hand-rolled panic that compared the buffer length but never stat'ed the file. Folded into `pin` so it gets the on-disk check. +### Site label + +The label is **`TEST_PIN`**, deliberately outside the `EC_AV1_*` env-var namespace: no +env var of that name exists (a real `EC_AV1_PIN` env var does — the scratch replay +helper's — and reusing that name would have pointed a triager at the wrong thing), and +every other failure-line label in this module names the env var that triggers the write. +`EC_AV1_GATE_DUMP` and `EC_AV1_SYMTRACE` keep their real env-var names because they *are* +real env vars. + ### `stream.rs:28143` — the warns-by-design site: decision Routed through `pin_reporting`, keeping it non-fatal. The two shapes differ for a stated reason, not by accident: - the nine sites run **inside the arm that is already panicking** — the pin exists to - feed that panic, so dying on a short pin replaces a message with a strictly better - one (same panic, plus the byte counts). + feed that panic, so dying on a short pin replaces a message with a strictly better one + (same panic, plus the byte counts). - 28143's real failure is the `assert_eq!` three lines below (luma/U/V vs ffmpeg). Panicking on the write would **mask that assert** with an unrelated filesystem error — the exact failure its comment refuses. So it must not be fatal. -What changed is what it *prints*: the old `could not pin to {path}: {e}` warning -became `cdfflake: ec-av1 dump FAILED [EC_AV1_PIN] {path}: wrote N of M bytes: {why}` — -same severity (a warning, then the asserts run), now carrying expected-vs-on-disk -counts. A truncated pin there was previously indistinguishable from a good one. +What changed is what it *prints*: the old `could not pin to {path}: {e}` warning became +`cdfflake: ec-av1 dump FAILED [TEST_PIN] {path}: wrote N of M bytes: {why}` — same +severity (a warning, then the asserts run), now carrying expected-vs-on-disk counts. A +truncated pin there was previously indistinguishable from a good one. ## Proof @@ -67,7 +84,7 @@ counts, not carrying on. ``` $ EC_AV1_PINLOUD_CHILD=/tmp/pincap2 bash -c 'ulimit -f 8; trap "" XFSZ; exec "$0" "$@"' \ --exact dumpio::tests::pin_child_under_cap --nocapture -ec-av1 dump FAILED [EC_AV1_PIN] /tmp/pincap2/cap-pinned.obu: wrote 8192 of 32768 bytes: +ec-av1 dump FAILED [TEST_PIN] /tmp/pincap2/cap-pinned.obu: wrote 8192 of 32768 bytes: write failed with 0 bytes confirmed in hand: File too large (os error 27) test dumpio::tests::pin_child_under_cap ... FAILED $ ls -l /tmp/pincap2 @@ -100,13 +117,14 @@ every `ec-*` crate: |---|---|---| | `ec-vorbis/tests/oracle.rs:1447,1452` | `let _ = fs::write` of sweep tables into `lanes/*.txt` | **Reported, not fixed.** Not the same shape: the path is not printed in a failure message, the file is a human-read report rather than a replay artefact, and the asserts that follow (`rows > 0`, `failures.is_empty()`) do not depend on it. Sibling lane material. | | `ec-ac3/examples/ac3dec.rs:89,96` | `let _ = out.write_all(..)` to raw stdout of an example decoder | **Reported, not fixed.** No path is named; a short write there is the encoder of a raw file a downstream `cmp` measures. Different class (unverified output, not a mis-pointed replay path). | -| `ec-h264/tests/encode.rs:475,1068`, `ec-h265/tests/encode.rs:289,341` | `std::fs::write(..).ok()?` feeding an `ffmpeg` subprocess | **Reported, not fixed.** `.ok()?` propagates the failure as `None` — the test helper bails rather than decoding a truncated file, so there is no silent-truncation path to close. | +| `ec-h264/tests/encode.rs:475,1068`, `ec-h265/tests/encode.rs:289,341` | `std::fs::write(..).ok()?` feeding an `ffmpeg` subprocess | **Reported, NOT fixed — half-open.** The `Err` path IS closed: `.ok()?` propagates the failure as `None` and the helper bails instead of running ffmpeg on a fragment. The `Ok`-but-short path is NOT closed: `fs::write` returning `Ok` does not guarantee the on-disk length — exactly the gap `LoudDump::finish()` exists to close — and these sites have no equivalent, the file going straight to ffmpeg as decoder input. Same mis-pointed-artefact family, one hop removed. A following lane should route these four through a loud writer; those crates have no shared helper yet, so the fix is per-crate. | -No sibling site has the "discard the error, then hand the reader that exact path" -shape. Fixed only `ec-av1`. +Two of the sibling shapes are open in the weaker sense above; none of the sibling sites +has the "discard the error, then hand the reader that exact path" shape. Fixed only +`ec-av1` (plus its own msac site). ## Notes for the reviewer -- Success path is byte-identical; the only behavioural delta is that a short pin is - now fatal (9 sites + 2 gate dumps + the symtrace flush) or loud-with-counts (28143). -- The `EC_AV1_PIN` site label is a new failure-line prefix; grep it when triaging. \ No newline at end of file +- Success path is byte-identical; the only behavioural delta is that a short pin is now + fatal (9 sites + 2 gate dumps + the symtrace flush) or loud-with-counts (28143). +- Grep `TEST_PIN` (not `EC_AV1_PIN`) when triaging a short-pin failure line. \ No newline at end of file