forge
Explore
Log in

Don't you dare go Hollow

Key the probe stream's temp file per call, not per process

Browse files at this commit

f9d5fb9f20479cf169ecf978979fd9b5853e6644Ahmet Kaan GümüşParent: 417cf64
  • fix
    • key the probe stream's temp file per call, not per process
Show full message
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.rsmodified+9 -1
@@ -2682,7 +2682,15 @@ mod tests {
2682 /// frame size an AV1 decoder allocates, not necessarily the render size2682 /// frame size an AV1 decoder allocates, not necessarily the render size
2683 /// (see [`a_frame_round_trips_at_its_own_size`]).2683 /// (see [`a_frame_round_trips_at_its_own_size`]).
2684 fn ffprobe_size(stream: &[u8]) -> (u32, u32) {2684 fn ffprobe_size(stream: &[u8]) -> (u32, u32) {
2685- let path = std::env::temp_dir().join(format!("ec-av1-probe-{}.obu", std::process::id()));2685+ // Distinct per call, not per process: the test binary runs callers on
2686+ // parallel threads, and a shared name lets one test's cleanup delete
2687+ // the stream another test's ffprobe is still reading.
2688+ static PROBE_SEQ: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
2689+ let path = std::env::temp_dir().join(format!(
2690+ "ec-av1-probe-{}-{}.obu",
2691+ std::process::id(),
2692+ PROBE_SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed)
2693+ ));
2686 let _ = std::fs::remove_file(&path);2694 let _ = std::fs::remove_file(&path);
2687 std::fs::write(&path, stream).expect("writing the probe stream");2695 std::fs::write(&path, stream).expect("writing the probe stream");
2688 let out = Command::new("ffprobe")2696 let out = Command::new("ffprobe")