Fix/dtvcc allocation panic#2050
Conversation
cfsmp3
left a comment
There was a problem hiding this comment.
Thanks for working on improving the robustness of the CEA-708 decoder initialization!
The concept is good - handling allocation failures gracefully instead of panicking. However, there are several issues that need to be fixed before this can be merged:
1. CRLF Line Endings Breaking Linux Builds
All files in this PR have Windows-style CRLF line endings instead of Unix LF:
decoder/mod.rs: ASCII text, with CRLF line terminators
pre-build.sh: ASCII text, with CRLF line terminators
This breaks the Linux build - shell scripts with CRLF don't work on Unix systems. This is why the CI is failing:
build_shell- FAILUREbuild_autoconf- FAILUREformat_rust- FAILURE
Fix: Configure your git to handle line endings properly:
git config --global core.autocrlf inputThen convert the files:
dos2unix src/rust/src/decoder/mod.rs linux/pre-build.shOr rebase your branch on a fresh master checkout.
2. Unrelated Changes from PR #2045
This PR includes changes from #2045 (userdata.rs documentation and debug logging). These should be in a separate PR - #2045 is already pending review.
Please remove src/rust/src/es/userdata.rs from this PR.
3. Messy Commit History
The commits include "retry the test" and "restore all changes" which don't describe the actual changes. Consider squashing into a clean commit with a descriptive message.
4. Minor: Trailing Whitespace
continue;
} // <-- extra spaces hereThe Actual Fix Looks Good
Once the above issues are fixed, the core change is reasonable:
// Before: panic on allocation failure
panic!("Failed to allocate dtvcc_tv_screen");
// After: log and gracefully skip the service
debug!(msg_type = DebugMessageFlag::DECODER_708;
"DTVCC: Failed to allocate tv_screen for service {}, disabling service", i + 1);
continue;The cleanup of the already-allocated tv_screen when decoder allocation fails is also correct:
unsafe {
std::alloc::dealloc(tv_ptr as *mut u8, tv_layout);
}Summary
Please:
- Fix line endings (dos2unix or fresh checkout)
- Remove userdata.rs changes (belongs in #2045)
- Squash commits into clean history
- Push updated branch
Looking forward to the updated PR!
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
This PR removes panics from the CEA-708 decoder initialization path.
Previously, allocation failures for dtvcc_tv_screen or
dtvcc_service_decoder would cause a hard panic, crashing CCExtractor.
Instead, allocation failures are now handled gracefully by logging
a debug message and disabling the affected service decoder while
allowing processing to continue.
This improves robustness and aligns Rust behavior with the legacy C
implementation.