Skip to content

Fix jitterbuffer - #422

Merged
thatsnotright merged 3 commits into
pion:mainfrom
solos:fix-jitterbuffer
Oct 8, 2026
Merged

thatsnotright merged 3 commits into
pion:mainfrom
solos:fix-jitterbuffer

Conversation

@solos

@solos solos commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Description

  1. Inserting a node with the same priority as the head previously created a
    bidirectional cycle (head.next = newPq && newPq.next = head), leading to
    infinite loops during Pop/Find. Rewrite the insertion logic to prevent
    circular references.

  2. Missing prev/next pointer updates in Pop / PopAt / PopAtTimestamp
    Removal did not update adjacent nodes' prev/next pointers nor clear the
    removed node's pointers, resulting in dangling references and preventing
    timely GC. Add proper pointer re-linking and cleanup in all removal paths.

3.Memory leak in Clear
Clear only set each node's prev to nil but left q.next pointing to the old
head, keeping the entire node chain reachable and preventing GC. Fix by
resetting q.next to nil so the chain becomes unreachable and collectible.

Reference issue

None

@codecov

codecov Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.67%. Comparing base (3d7134a) to head (6723ee4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #422      +/-   ##
==========================================
+ Coverage   85.62%   85.67%   +0.04%     
==========================================
  Files          91       91              
  Lines        3986     3985       -1     
==========================================
+ Hits         3413     3414       +1     
+ Misses        573      571       -2     
Flag Coverage Δ
go 85.67% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

solos and others added 3 commits October 7, 2026 20:27
Critical defects addressed:

1. Circular list in Push Inserting a node with the same priority as the
head previously created a bidirectional cycle (head.next = newPq &&
newPq.next = head), leading to infinite loops during Pop/Find. Rewrite
the insertion logic to prevent circular references.

2. Missing prev/next pointer updates in Pop / PopAt / PopAtTimestamp
Removal did not update adjacent nodes' prev/next pointers nor clear the
removed node's pointers, resulting in dangling references and preventing
timely GC. Add proper pointer re-linking and cleanup in all removal
paths.

3. Memory leak in Clear Clear only set each node's prev to nil but left
q.next pointing to the old head, keeping the entire node chain reachable
and preventing GC. Fix by resetting q.next to nil so the chain becomes
unreachable and collectible.
Initialize PriorityQueue and node pointer fields explicitly
in NewQueue and newNode.
@thatsnotright
thatsnotright merged commit 780f4ef into pion:main Oct 8, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants