From f9d5fb9f20479cf169ecf978979fd9b5853e6644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 27 Aug 2026 04:14:34 +0300 Subject: [PATCH] fix(av1): key the probe stream's temp file per call, not per process ffprobe_size named its temp file by process id alone, so every test in the binary shared one path; a parallel test's cleanup could delete the stream another test's ffprobe was mid-read on. This was the recurring first-run gate flake (127/2 after 3cb60f6, 128/1 after 78fc36c) -- an atomic counter now makes each call's path distinct. --- crates/ec-av1/src/encode.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index ef13644a..4aa0bda6 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -2682,7 +2682,15 @@ mod tests { /// frame size an AV1 decoder allocates, not necessarily the render size /// (see [`a_frame_round_trips_at_its_own_size`]). fn ffprobe_size(stream: &[u8]) -> (u32, u32) { - let path = std::env::temp_dir().join(format!("ec-av1-probe-{}.obu", std::process::id())); + // Distinct per call, not per process: the test binary runs callers on + // parallel threads, and a shared name lets one test's cleanup delete + // the stream another test's ffprobe is still reading. + static PROBE_SEQ: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); + let path = std::env::temp_dir().join(format!( + "ec-av1-probe-{}-{}.obu", + std::process::id(), + PROBE_SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed) + )); let _ = std::fs::remove_file(&path); std::fs::write(&path, stream).expect("writing the probe stream"); let out = Command::new("ffprobe")