Skip to content

Fix segfault: keep Graph alive from held filter ctx - #2380

Merged
WyattBlue merged 5 commits into
mainfrom
patch
Aug 15, 2026
Merged

Fix segfault: keep Graph alive from held filter ctx#2380
WyattBlue merged 5 commits into
mainfrom
patch

Conversation

@WyattBlue

Copy link
Copy Markdown
Member

A FilterContext held a weakref to its Graph, so dropping the Graph freed the underlying AVFilterContext while the context was still held. Using it (push/link_to/process_command) then dereferenced freed memory. Make _graph a strong ref; the Graph<->context cycle is collected by gc.

A FilterContext held a weakref to its Graph, so dropping the Graph freed
the underlying AVFilterContext while the context was still held. Using
it (push/link_to/process_command) then dereferenced freed memory. Make
`_graph` a strong ref; the Graph<->context cycle is collected by gc.
- push() to a buffer source before the graph is configured dereferenced
  uninitialized graph internals. Auto-configure first, mirroring pull().
- add_stream_from_template() dereferenced a template Stream's AVStream ptr
  without checking its source container was still open. Guard with
  _assert_open().
FilterPad.__repr__ and FilterContextPad.__repr__ referenced self.type,
which was never defined, so repr() of any pad raised AttributeError. Add
a type property via avfilter_pad_get_type, mirroring the name property.
`_context_by_type` already indexes them, which is how the sink side reads
its contexts.
__basicsize__ 80 -> 72.
@WyattBlue
WyattBlue merged commit 4cba10e into main Aug 15, 2026
@WyattBlue
WyattBlue deleted the patch branch August 15, 2026 20:56
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.

1 participant