Skip to content

media-playback: Return the packet to the pool when a read fails - #466

Merged
zackees merged 1 commit into
masterfrom
fix/463-media-packet-leak
Oct 13, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/463-media-packet-leak

Conversation

@zackees

@zackees zackees commented Oct 13, 2026

Copy link
Copy Markdown
Member

Closes #463.

mp_media_next_packet takes a packet from packet_pool (or av_packet_allocs one) before av_read_frame. On a failed read (a network timeout, EOF, AVERROR_EXIT) it returned without putting the packet back, so the packet leaked. LeakSanitizer and valgrind both reported it from test_media_network_timeout (master's run 38351762501: av_malloc ← mp_media_next_packet media.c:176 ← mp_media_reset). Upstream OBS code, unchanged in this fork.

Fix: mp_media_free_packet(media, pkt) on the error path. That unrefs the packet and returns it to the pool, which mp_media_free drains.

Evidence: the leak only shows under a sanitizer (Tier 2 doesn't run ASan), so the RED is master's ASan run above and the GREEN is the ASan pass on this branch, run 38356256911. Its result will be posted here. Tier 2 --repeat 3 --tests test_media passes OFF/ON (7/7), and the local gate passed and is stamped.

mp_media_next_packet takes a packet from the pool (or allocates one)
before av_read_frame, and on a failed read (a network timeout, EOF, an
abort) returned without putting it back, so it leaked. LeakSanitizer
and valgrind both reported it from test_media_network_timeout.

Closes #463

Local-Gate: v1 tree=6d9a78ce9a7323dd24a5e7fca4ce6bac145f9707 secs=359 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791872495,"gate":"rust/all/fmt","host":"linux-x86_64","key":"458ee7e0887c6798f14897589ce78f638a4992ee0d2d42e4e20ea9d86b2eb84d","lane":"lint","parents":["1c3961ae138b65e4690a1b9396f713f68db9e7cc"],"secs":37,"stamp":"e5e1aa47fd7f0e1b028495bf3aaa4444","tree":"6d9a78ce9a7323dd24a5e7fca4ce6bac145f9707","v":1,"via":"run"}
Ci-Attestation: {"at":1791872495,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"458ee7e0887c6798f14897589ce78f638a4992ee0d2d42e4e20ea9d86b2eb84d","lane":"lint","parents":["1c3961ae138b65e4690a1b9396f713f68db9e7cc"],"secs":37,"stamp":"227677642eef9ace75b364935ffcde73","tree":"6d9a78ce9a7323dd24a5e7fca4ce6bac145f9707","v":1,"via":"run"}
Ci-Attestation: {"at":1791872495,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"ba396a812f84bd8ea4be071002de130266fb0db2b6ea16bc17cdb3ae0a78facf","lane":"rust-test","parents":["1c3961ae138b65e4690a1b9396f713f68db9e7cc"],"secs":239,"stamp":"f3ae09b965dd163064621d43e445a37e","tree":"6d9a78ce9a7323dd24a5e7fca4ce6bac145f9707","v":1,"via":"run"}
Ci-Attestation: {"at":1791872495,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"a9701f427ed32186eb589780bb4727f148fa4271ed7e6cfcc34e28e7bc795a19","lane":"tier2-linux","parents":["1c3961ae138b65e4690a1b9396f713f68db9e7cc"],"secs":82,"stamp":"42b4ac2617491e708fff05a042441dc5","tree":"6d9a78ce9a7323dd24a5e7fca4ce6bac145f9707","v":1,"via":"run"}
@zackees

zackees commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

ASan pass on this branch (run 38356256911): test_media_network_timeout no longer appears in the findings. It was the mp_media_next_packet leak on master's run 38351762501.

@zackees
zackees merged commit 3410e7b into master Oct 13, 2026
20 checks passed
@zackees
zackees deleted the fix/463-media-packet-leak branch October 26, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: media-playback: mp_media_next_packet leaks a packet on the reset path

1 participant