diff --git a/quest/m1/fuzz-findings/README.md b/quest/m1/fuzz-findings/README.md index 7992ba83af4..30e2a7d8848 100644 --- a/quest/m1/fuzz-findings/README.md +++ b/quest/m1/fuzz-findings/README.md @@ -37,7 +37,6 @@ fixed the MKV block-header panic; its input is ## Required - [moq-mux on a fixed mp4-atom](/quest/m1/fuzz-findings/mp4-atom-bump.md) - waiting on a 0.17.x release containing kixelated/mp4-atom#264, then moq-mux bumps to it and commits the `sgpd` and `iref` regressions -- [TS step scan stays ordered](/quest/m1/fuzz-findings/ts-step-scan.md) - the step detector's look-ahead never subtracts past its start - [SPS fields cannot overflow](/quest/m1/fuzz-findings/sps-overflow.md) - hostile H.264 and H.265 SPS crop and size fields are refused instead of wrapping - [mp4-atom iloc is bounded](/quest/m1/fuzz-findings/mp4-atom-iloc.md) - zero-size `iloc` extents cannot allocate megabytes from a few bytes - [A catalog update reuses its encoder](/quest/m1/fuzz-findings/catalog-encoder.md) - republishing a compressed catalog or HLS group stops allocating a fresh DEFLATE encoder (about 200 KB) each time diff --git a/quest/m1/fuzz-findings/ts-step-scan.md b/quest/m1/fuzz-findings/ts-step-scan.md deleted file mode 100644 index a249bf7006d..00000000000 --- a/quest/m1/fuzz-findings/ts-step-scan.md +++ /dev/null @@ -1,19 +0,0 @@ -# [S] TS step scan stays ordered - -## Goal - -The MPEG-TS step detector's look-ahead never reads with `scan < at`, so its -`self.scan - self.at` staging check (`rs/moq-mux/src/container/ts/step.rs`, -`Ahead::scan`) neither overflows in debug nor wraps in release, which cut -the look-ahead short. The `ts` target's 567-byte input is committed under -`rs/moq-mux/fuzz/regressions/` and passes. - -## Plan - -Find how an `Ahead` gets a `scan` cursor behind its `at` (the input offset of -the packet that showed the step) from the input in the -[findings comment](https://github.com/moq-dev/moq/pull/7313#issuecomment-6520535160), -and fix the cause rather than saturating the subtraction. A unit test in -`step.rs` reproduces it with the module's `pes` helper. - -Public API: none. Wire: none. diff --git a/rs/moq-mux/fuzz/regressions/ts/step-scan b/rs/moq-mux/fuzz/regressions/ts/step-scan new file mode 100644 index 00000000000..87c245ffe32 Binary files /dev/null and b/rs/moq-mux/fuzz/regressions/ts/step-scan differ diff --git a/rs/moq-mux/src/container/ts/step.rs b/rs/moq-mux/src/container/ts/step.rs index 457ebabe753..7ef56c29706 100644 --- a/rs/moq-mux/src/container/ts/step.rs +++ b/rs/moq-mux/src/container/ts/step.rs @@ -278,7 +278,7 @@ struct Ahead { back: Option, /// The first PCR read since, which times how long the silent streams are waited for. since: Option, - /// The next input offset to read, and the framer's state there. + /// The next input offset to read, never before `at`, and the framer's state there. scan: u64, framer: Framer, /// The step, once every clock confirmed it. @@ -292,7 +292,6 @@ impl Steps { self.clock = routes.pcr_pid.map(|pid| (pid, None)); } let (mut cursor, mut framer) = demux.cursor(); - let start = (cursor, framer); let Some((at, pkt)) = demux.peek(&mut cursor, &mut framer) else { return Verdict::Route; }; @@ -300,7 +299,7 @@ impl Steps { let marks = Marks::read(pkt, routes, &self.headers); if self.ahead.is_none() && at >= self.cleared { - self.ahead = self.trigger(at, pid, &marks, routes, start); + self.ahead = self.trigger(at, pid, &marks, routes, framer); } let Some(ahead) = &mut self.ahead else { self.observe(pid, marks, routes); @@ -342,15 +341,9 @@ impl Steps { } /// Start judging a step at the packet at `at` if it shows one, with the clocks expected to - /// step with it. - fn trigger( - &self, - at: u64, - pid: u16, - marks: &Marks, - routes: &Routes, - (scan, framer): (u64, Framer), - ) -> Option { + /// step with it. `framer` is locked onto that packet, so the scan reads it again from `at` + /// rather than from the junk a resync skipped before it. + fn trigger(&self, at: u64, pid: u16, marks: &Marks, routes: &Routes, framer: Framer) -> Option { let last_pcr = self.clock.and_then(|(_, last)| last); let stepped = if marks.flagged { None @@ -397,7 +390,7 @@ impl Steps { headers: self.headers.clone(), back: None, since: None, - scan, + scan: at, framer, confirmed: None, }) @@ -631,6 +624,24 @@ mod tests { assert_eq!(judge(&mux.out, &[VIDEO]), None); } + /// Junk before the switch, such as a torn packet at the splice, makes the framer resync onto + /// the packet that shows the step, past the cursor. The look-ahead reads on from that + /// packet, not from the junk, so the switch is still judged whole. + #[test] + fn a_resync_before_the_step_reads_on_from_it() { + let (mut mux, mut cc) = (Mux::default(), 0); + second(&mut mux, &mut cc, PCR_HZ, true); + mux.out.extend_from_slice(&[0x00; 5]); + second(&mut mux, &mut cc, PCR_WRAP + 2 * PCR_HZ - SWITCH, true); + let Some(Step::Rewind { by, flagged: false }) = judge(&mux.out, &[VIDEO]) else { + panic!("the switch was missed"); + }; + assert!( + by.abs_diff(Duration::from_millis(16_844_460)) < Duration::from_millis(100), + "{by:?}" + ); + } + /// A PES header split across packets still times its stream, so the switch is seen. #[test] fn a_split_pes_header_steps_with_the_clock() {