Skip to content

bug: libobs: obs_wait_for_destroy_queue skips the video thread when audio is not reset (flaky lifetime tests) #5405

Closed

Description

@rdoupe

Location

libobs/obs.c.h:2954, obs_wait_for_destroy_queue():

if (obs->video.thread_initialized && obs->audio.audio) {
	obs_queue_task(OBS_TASK_GRAPHICS, task_wait_callback, &info, false);
	task_wait_for_callback(&info);
	obs_queue_task(OBS_TASK_AUDIO, task_wait_callback, &info, false);
	task_wait_for_callback(&info);
}

Class

Logic error (race; flaky tests)

How it is reached

The video thread waits only when audio was reset as well. tick_sources() (libobs/obs-video.c.h:47) takes a reference on every source, private ones included, while it ticks it. A caller that runs video without audio, releases a source, waits for the destroy queue and then checks a weak reference can still see the tick's reference.

26 cmocka fixtures reset video without audio and call obs_wait_for_destroy_queue(). One of them failed the master push run of #5356 (Rust Tier 2 Linux, tests OFF): test_scene_item_transition_serialization_lifetime.c:107: obs_weak_source_expired(old) is not true (https://github.com/obs-rust/obs-studio/actions/runs/44895576535). The test did not change in that merge.

A real OBS session always resets audio, so users don't hit this. It shows up as flaky tests.

Proposed fix and failing test

Wait for the graphics task whenever the video thread runs, and for the audio task whenever audio exists, as two separate checks.

RED: a new cmocka test, test_destroy_queue_video_sync, resets video only. A private source's video_tick blocks while the test releases its own reference, and the test then asserts that the weak reference has expired after obs_wait_for_destroy_queue(). Before the fix the assertion fails every time; after it, it passes.

Activity

  1. added
    bug
    on Nov 21, 2026
  2. rdoupe commented on Nov 21, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: red master fix. RED test written and failing locally (Tier 2 linux-validate: test_destroy_queue_video_sync.c:107: obs_weak_source_expired(weak) is not true); PR follows.

  3. added
    ready
    on Nov 21, 2026
  4. added a commit that references this issue on Nov 21, 2026
    d8562f7
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