Skip to content

bug: libobs: obs_transition_load leaks the source already in slot A #2582

Closed

Description

@rdoupe

Location

libobs/obs-source-transition.c.h, obs_transition_load():

	lock_transition(tr);
	tr->transition_sources[0] = source;
	tr->transition_source_active[0] = true;
	...
	unlock_transition(tr);

Class

Logic error: reference leak, and an active-child count that is never taken back.

How it is reached

obs_transition_load() writes the loaded source into slot A without taking what was there. If the transition already holds a source in slot A, that source's reference is lost, so it is never destroyed. If the slot was active, the source also stays counted as an active child of the transition: it stays active (and showing, while the transition is shown) after the transition moved on.

obs_load_sources() creates every source first, then loads each transition and calls the callback for each source in order. So a source set into a transition before that transition is loaded (by the obs_load_sources() callback for an earlier source, or by a plugin's create) is dropped this way. obs_transition_clear() and obs_transition_set() both take the old source back; the load should too.

No upstream issue; upstream obs-studio has the same code.

Proposed fix and failing test

Fix: take the old slot-A source and its active flag under the transition lock, as obs_transition_clear() does; after unlocking, remove it from the active children if the slot was active, then release it.

Test (RED): a cmocka test (Linux, core video, like the other transition tests) that loads a transition with obs_load_sources() while slot A already holds a leaf source shown through output channel 0, then checks that the leaf is no longer active or showing and that releasing the test's own reference destroys it. Controls: a load onto an empty slot, and a load of the same source that is already in the slot.

Activity

  1. added
    bug
    on Oct 27, 2026
  2. rdoupe commented on Oct 27, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2582.

    1. RED: a cmocka test (Linux, core video) that loads a transition through obs_load_sources() while slot A already holds a shown leaf, and checks the leaf is deactivated, hidden and destroyed once released; controls for an empty slot and for reloading the same source.
    2. GREEN: obs_transition_load() takes the old slot-A source and its active flag under the lock and, after unlocking, removes it from the active children (if active) and releases it, as obs_transition_clear() does.
    3. features.md line.

    Draft PR with the RED commit today, GREEN shortly after.

  3. added
    ready
    on Oct 27, 2026
  4. rdoupe commented on Oct 27, 2026

    @rdoupe
    CollaboratorAuthor

    Fixed by PR #2584 (merged through the merge queue): obs_transition_load() now takes the old slot-A source and its active flag under the transition lock and, after unlocking, removes it from the active children if the slot was active and releases it, as obs_transition_clear() does. The new test_transition_load_release (graphics suite) covers the shown, hidden and same-source cases plus an empty-slot control.

    Nothing is left from this issue, so there is no follow-up issue. No upstream issue exists; upstream obs-studio has the same code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions