Fix rfc8888 implementation#425
Conversation
|
Thanks @5ur3! I will get this merged now and cut a release :) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #425 +/- ##
==========================================
- Coverage 80.05% 80.05% -0.01%
==========================================
Files 88 88
Lines 4608 4617 +9
==========================================
+ Hits 3689 3696 +7
- Misses 736 737 +1
- Partials 183 184 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I will fix linter errors shortly |
There was a problem hiding this comment.
Pull request overview
This PR addresses two correctness/stability issues in the RFC 8888 feedback implementation: preventing unbounded in-memory growth in per-stream packet logs and ensuring report-size budgeting cannot go negative (avoiding panics).
Changes:
- Prevent
streamLogmemory growth by dropping late/duplicate packets below the report pointer and reclaiming skipped entries when applying the report-block cap. - Clamp the computed report-block budget to a non-negative value to avoid
make()panics when many SSRCs are present. - Add tests covering both the stream-log reclamation behavior and the non-positive per-stream budget scenario.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/rfc8888/stream_log.go | Drops packets below the report pointer and deletes log entries that would otherwise be skipped and leaked when capping report blocks. |
| pkg/rfc8888/stream_log_test.go | Adds regression tests ensuring the stream log does not retain entries below the report pointer. |
| pkg/rfc8888/recorder.go | Clamps report-block budget to avoid negative lengths in slice allocation. |
| pkg/rfc8888/recorder_test.go | Adds test ensuring large SSRC counts don’t cause panics and produce empty per-stream metric blocks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| maxReportBlocks := max((maxSize-12-(8*len(r.streams)))/2, 0) | ||
| maxReportBlocksPerStream := maxReportBlocks / len(r.streams) | ||
|
|
There was a problem hiding this comment.
Seems that such division by zero is unreachable (len(r.streams) is at least 1 when this code is triggered)
There was a problem hiding this comment.
both BuildReport and NewRecorder are public. so it's reachable in custom user code.
There was a problem hiding this comment.
@JoTurk should I update this PR manually? Or will you commit this suggestion?
There was a problem hiding this comment.
up to you :) you can apply it and amend your commit if you want, so it doesn't create extra noisy commit.
There was a problem hiding this comment.
I will just create extra commit myself
c22b4d6 to
b5a0882
Compare
|
should have squash merged. |
skill issue, I'm not using github a lot :) I'll remember that for next time |
Description
Issue 1 - unbounded growth of streamLog.log (memory exhaustion).
Entries are only removed while metricsAfter iterates upward from nextSequenceNumberToReport, so any entry left below that pointer is never freed. An entry lands below the pointer three ways:
Issue 2 - possibility of make() called with negative len.
metricsAfter allocates its metricBlocks slice with a length up to maxReportBlocks. That value is derived in recorder.go from maxSize and the number of distinct SSRCs; with enough SSRCs in a session it becomes negative, so make() is called with a negative length and panics.