Repository navigation
HEVCParser: don't loop forever on a NAL header with forbidden_zero_bit set - #1529
Merged
kmdewaal merged 1 commit intoNov 5, 2026
Merged
Conversation
…t set addBytes() returns the number of bytes used, but the forbidden_zero_bit error path returned "false", i.e. 0. DTVRecorder::FindHEVCKeyframes() then does "i += bytes_used - 1" and "++i", so it hands the parser the same bytes again, the parser finds the same start code, logs the same error and returns 0 again: the recorder thread never leaves that TS packet. The log queue grows by ~85k messages/s until the kernel's OOM killer kills mythbackend (20 GB RSS on a 32 GB machine), taking every recording in progress with it. A DVB-T2 reception error only has to produce 00 00 01 followed by a byte >= 0x80 in the HEVC payload. Reproduced by planting 00 00 01 80 01 in one video TS packet of a clean recording replayed through an External Recorder: 79 MB -> 5.5 GB RSS in 90 s, recording split in two. With this change: one log line, RSS flat, recording complete. Skip the bad NAL header (reset the RBSP state and report the bytes used up to and including it), as the function's other early return does. The same code is in fixes/35, fixes/36 and master. Resolves: MythTV#1528 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Resolves #1528
HEVCParser::addBytes()returns the number of bytes used, but itsforbidden_zero_biterror path returnedfalse, which is 0.DTVRecorder::FindHEVCKeyframes()then doesi += (bytes_used - 1)and++i, hands the parser the same bytes again, and the recorder thread loops on that TS packet forever. Each pass logs the error, and the log queue grows until the OOM killer kills mythbackend, along with every recording in progress.This change skips the bad NAL header the same way the function's other early return does:
resetRBSP(); return startP - bytes;.startPis already past the header byte, so the result is always >= 1.Testing (on fixes/34, the Ubuntu 24.04 package rebuilt with this change; master's lines are identical):
00 00 01 80 01planted in one video TS packet, played through an External Recorder input.The same code is in fixes/34, fixes/35 and fixes/36, so a backport would help those branches too.
Checklist
🤖 Generated with Claude Code