Skip to content

libobs: every output stop leaks its end_data_capture thread (never joined) #2063

Closed

Description

@zackees

TSan (run 40066620813) reports a thread leak at obs_output_end_data_capture_internal (obs-output.c.h:2356 and :2387): 82 reports in 18 tests.

end_data_capture_thread clears end_data_capture_thread_active when it finishes. Each of the three join sites (the next start, the next end of capture, and destroy) joins only if (data_capture_ending(output)), so a thread that has already finished is never joined, and each stop leaks one joinable thread and its stack. null-output had the same bug and it was fixed there (test_null_output_stop_thread).

Fix: track whether a created thread is still unjoined, separately from whether it's running, and join on that. Test: a new cmocka test interposes pthread_create, pthread_join and pthread_detach, then checks that unjoined threads don't grow with the number of start/stop cycles of a raw output.

Activity

  1. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Claiming: RED interposed-pthread test, GREEN joinable flag in obs-output. PR today.

  2. added
    claimed
    on Oct 24, 2026
  3. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Fixed by #2070 (merged). A separate joinable flag means the next start, the next end of capture, and destroy now join a finished end_data_capture thread. Before the fix, test_output_end_capture_thread_join failed with 4 threads left unjoined after 4 stops.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions