[FIX]: Prevent CEA-708 decoder panic with -stdout on Windows #1880
+27
−15
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):
My familiarity with the project is as follows (check one):
Fix #1478: Prevent CEA-708 service decoder panic when using
-stdouton WindowsIssue Summary
Issue #1478 reports a panic in CCExtractor 0.94 when using
-stdoutwith HDHomeRun-recorded.tsfiles on Windows:Original crash reported:
Reproduction
I reproduced a similar panic on Windows 0.94 portable build using
-stdout:My reproduction:
Root Cause Analysis
Although the panics are reported at different line numbers across builds, they stem from the same underlying issue in the CEA-708 service decoder.
On Windows, when running with
-stdout, transcript output is effectively disabled or not fully initialized (no output filename, different writer setup). However, the decoder still executes code paths that assume a fully configured transcript writer.This results in panics in different places depending on build and execution path:
Failed
Writer::new()being unconditionally used (e.g. “Filename missing”)Accessing a non-existent writer context (index out of bounds)
While the exact panic location varies, both failures indicate that writer-related state is accessed when transcript output is not valid.
This fix adds an explicit check for
transcript_settingsand exits early when transcript output is disabled, preventing invalid writer usage. Behavior when transcript output is enabled remains unchanged.Changes Made
Modified
src/rust/src/decoder/service_decoder.rsto add defensive checks in two methods:1.
screen_print()method:transcript_settingsexists before attempting Writer creation.unwrap()call that caused the panic2.
flush()method:transcript_settingsTesting
Cross-platform tested:
Request for Windows testing
Why This Fix Should Work
Even though the panic line numbers differ between the original report (275) and my reproduction (897), this fix addresses what appears to be the root cause based on available evidence:
The Fix Strategy:
Before any Writer operations, check if transcript output is properly configured
If not configured, skip transcript output gracefully instead of attempting to use an uninitialized Writer
This should prevent panics at any point where Writer is accessed (creation, usage, or cleanup)
Even if this doesn't address the exact root cause of the line 275 panic (due to build differences or additional factors), the fix provides important safety guarantees:
Prevents panics from null/missing transcript_settings
Fails gracefully instead of crashing
At minimum, this fix makes the codebase more robust against Writer initialization issues on Windows.