Repository navigation
Conversation
…oder
Two panics in the Rust 708 decoder abort the whole run ("panic in a
function that cannot unwind") on US OTA MPEG-2 broadcasts. Both reproduce
on 0.96.5 and on current master; the C decoder already rejects the same
input since CCExtractor#1961.
1. EXT1 + G2/G3 character with no current window
panicked at src/decoder/service_decoder.rs:1142:27:
index out of bounds: the len is 8 but the index is 18446744073709551615
process_character() indexed windows[current_window as usize] before
its own `current_window == -1` check. G0/G1/P16 check in their
handlers, but handle_extended_char() calls process_character()
directly. Seen after RST, and after DLW at an edit point.
Fix: check current_window before indexing.
2. Set Pen Location to row 15
panicked at src/decoder/service_decoder.rs:1168:21:
index out of bounds: the len is 15 but the index is 15
SPL takes a 4-bit row (0-15) unchecked, but rows[] holds
CCX_DTVCC_MAX_ROWS (15). One broadcast sends SPL row 15 in a 4-row
window, then text.
Fix, as in the C decoder (CCExtractor#1961):
- SPL rejects a pen location outside the current window (pen unchanged)
- DefineWindow rejects a window larger than CCX_DTVCC_MAX_ROWS x
CCX_DTVCC_MAX_COLUMNS (the row field allows 16)
- process_character drops a character whose pen is outside the grid
The DefineWindow check also stops a 16-row window from overrunning rows[]
in copy_to_screen and rollup.
Not changed, noted for a follow-up: process_cr with BOTTOM_TOP print
direction sets pen_row = row_count (and RIGHT_LEFT sets pen_column =
col_count), one past the window. With a 15-row window, a following HCR
calls clear_row(15) and overruns rows[]. The C decoder has the same
pattern. No sample hits it.
Tests: SPL rejection, no-window extended characters, out-of-grid pen,
oversized DefineWindow. The four fail on master (two at the panic sites
above). test_handle_set_pen_location now defines a 15x64 window so
row 14 / col 63 are valid, and sets the reserved high bits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
CCExtractor CI platform finished running the test files on linux. 171/238 tests matched the approved output:
67 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.
Compared with the tip of master — test 10180, commit 2c1c1c6:
Compared with the commit this branch was cut from: the same run as the tip of master (test 10180), so the comparison above already covers it. No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In raising this pull request, I confirm the following (please check boxes):
Reason for this PR:
Sanity check:
A note first: I have only a little Rust experience. I ran into these crashes on my own over-the-air recordings and worked on the fix with an AI assistant (Claude). I've read through the change and tested it as described below, but I'd be grateful for corrections on anything that isn't idiomatic, or on how you'd rather this be handled.
The problem
Two panics in the Rust CEA-708 decoder abort the whole run (
panic in a function that cannot unwind, exit 134). The 708 decoders run by default, so this also kills a plain 608 extraction such asccextractor -in=ts file.ts -out=ass, which is how I found it. They reproduce on 0.96.5 and on current master (2c1c1c6).Extended character with no current window
process_character()indexeswindows[current_window as usize]before it checkscurrent_window == -1. The G0, G1 and P16 handlers check first, buthandle_extended_char()callsprocess_character()directly. In my samples an EXT1 + G2 character (10 7D,10 20) arrives afterRST, or afterDLWat an edit point.Set Pen Location to row 15
SPL takes a 4-bit row (0-15) without checking it, but
rows[]holdsCCX_DTVCC_MAX_ROWS(15). One broadcast sends SPL row 15 inside a 4-row window, followed by text.The C decoder already rejects both inputs, since the fix for #1961 (82109e6); the Rust decoder didn't get the same guards.
The change
All in
src/rust/src/decoder/service_decoder.rs, following the C decoder's checks from the #1961 fix:process_character()checkscurrent_windowbefore indexing, and drops a character whose pen is outside theCCX_DTVCC_MAX_ROWSxCCX_DTVCC_MAX_COLUMNSgrid.handle_set_pen_location()rejects a pen location outside the current window (the pen stays where it was), asdtvcc_handle_SPL_SetPenLocationdoes.handle_define_windows()rejects a window larger thanCCX_DTVCC_MAX_ROWSxCCX_DTVCC_MAX_COLUMNS, asdtvcc_handle_DFx_DefineWindowdoes. This also stops a 16-row window from reading pastrows[]incopy_to_screenandrollup.test_handle_set_pen_locationnow defines a 15x64 window so its row 14 / column 63 are inside it.Repro instructions
Samples: ccextractor_cea708_panic_samples.zip (Google Drive, 2.6 MB). It holds three clips of about 3 seconds each, cut from US ATSC 1.0 MPEG-2 recordings as plain byte ranges of whole TS packets (no remux), plus a README and the full logs below.
cea708_spl_row15_crossing_jordan.tscea708_no_window_after_rst_librarians.tsRST, then10 7Dcea708_no_window_after_edit_quarantine.tsDLW FF, then10 20after a byte-level edit spliceOn each clip, either of these commands reproduces it:
logs/in the zip has the complete output of both commands on each clip, for both builds.Testing
cargo testinsrc/rustandsrc/rust/lib_ccxrpasses (452, 57 and 46 tests), on the pinned 1.99.1 toolchain under Linux.cargo fmt --checkis clean.cargo clippy --all-targetsshows only the warning that is already on master (service_decoder.rs:1530,byte_char_slices).service_decoder.rsunchanged. Two of them panic at the same two lines as above..assoutput is line-for-line identical to what 0.96.5 produced from a copy where I'd manually changed the one SPL byte, so 608 output is unaffected.Not included
rows[], to see whether the panic could still be reached some other way.process_cr()with BOTTOM_TOP print direction setspen_row = row_count, one past the window (RIGHT_LEFT does the same withpen_column). With a 15-row window, a following HCR would callclear_row(15)and overrunrows[]. The C decoder has the same pattern. I don't have any recordings that trigger it, so I haven't worked on a fix.service_decoder.rs. If it merges first, I'll rebase.I've used CCExtractor for over a decade and greatly appreciate the work of all the maintainers and contributors. Hopefully this patch can help someone else.
🤖 Generated with Claude Code