Skip to content

fix(tsnorm): survive parse errors, stop permanent raw passthrough (A-4)#13

Merged
ntt0601zcoder merged 1 commit into
mainfrom
fix/tsnorm-restart
Jun 13, 2026
Merged

fix(tsnorm): survive parse errors, stop permanent raw passthrough (A-4)#13
ntt0601zcoder merged 1 commit into
mainfrom
fix/tsnorm-restart

Conversation

@ntt0601zcoder

Copy link
Copy Markdown
Owner

Fixes audit finding A-4. A single astits parse error (one truncated UDP datagram / corrupt adaptation field) killed the tsnorm demux goroutine: runDemux returned, demuxDone closed, and every later Process returned io.EOF while n.started stayed true — the worker then fell back to un-normalised raw passthrough forever with no self-heal (raw bytes keep flowing so the stall watchdog never fires), breaking DASH AST/tfdt + HLS timing.

  • runDemux rebuilds the demuxer on a parse error and resyncs on the next sync byte, capped at maxDemuxRestarts=8 (mirrors pull.TSDemuxPacketReader).
  • Process resets n.started when it observes demuxDone, so a goroutine that does give up is relaunched lazily on the next call.

A transient corruption now costs at most one passthrough chunk, not permanent un-normalised output. Test TestProcess_RecoversFromParseError; go test -race + golangci-lint green.

…raw passthrough

A single astits parse error (one truncated UDP datagram, a corrupt adaptation
field) killed the tsnorm demux goroutine: runDemux returned, demuxDone closed,
and every later Process returned io.EOF while n.started stayed true — the worker
then fell back to un-normalised raw passthrough forever, with no self-heal
(raw bytes keep flowing so the stall watchdog never fires). This broke DASH
AST/tfdt + HLS timing with a mid-stream PID/timestamp-domain change (A-4).

- runDemux rebuilds the demuxer on a parse error and resyncs on the next sync
  byte, capped at maxDemuxRestarts=8 (mirrors pull.TSDemuxPacketReader).
- Process resets n.started when it observes demuxDone, so a goroutine that does
  give up is relaunched lazily on the next call.

Regression test TestProcess_RecoversFromParseError. Fixes audit finding A-4.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 53.84615% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/ingestor/tsnorm/tsnorm.go 53.84% 5 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@ntt0601zcoder ntt0601zcoder merged commit 0bfe7e8 into main Jun 13, 2026
4 checks passed
@ntt0601zcoder ntt0601zcoder deleted the fix/tsnorm-restart branch June 13, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants