Skip to content

fix(output): join a finished end_data_capture thread - #2070

Merged
zackees merged 4 commits into
masterfrom
fix/output-end-capture-thread-join
Oct 24, 2026
Merged

zackees merged 4 commits into
masterfrom
fix/output-end-capture-thread-join

Conversation

@zackees

@zackees zackees commented Oct 24, 2026

Copy link
Copy Markdown
Member

Fixes #2063

end_data_capture_thread clears end_data_capture_thread_active when it returns, and every join site joined only while that flag was set. So a finished thread was never joined, and each output stop leaked a joinable thread and its stack. TSan reported it in 18 tests, 82 reports (run 40066620813).

  • RED (first commit): the new test_output_end_capture_thread_join interposes pthread_create, pthread_join and pthread_detach in the executable, which is built with default visibility so that libobs binds to them. It runs 4 start/stop cycles of a raw video output, then releases it. Local ./unittest: 11 threads created, 4 left unjoined, 4 != 0.
  • GREEN: a separate end_data_capture_thread_joinable flag, set when a create succeeds. One join_end_data_capture_thread() helper (an atomic exchange, then join) now serves the next start, the next end of capture, and destroy. The shutdown-unstarted-encoders path joins a finished thread before it creates a new one, which never waits. ./lint passes; PR CI runs Tier 2 against both libobs builds.

obs-internal.h is a private header. Tiers 1 and 3 don't apply: obs-output has no Rust port.

@zackees
zackees enabled auto-merge October 24, 2026 06:52
@zackees

zackees commented Oct 24, 2026

Copy link
Copy Markdown
Member Author

The first CI run failed to build: join_end_data_capture_thread was called with the const output of the public obs_output_can_begin_data_capture (-Werror=discarded-qualifiers). That call now goes through (struct obs_output *)(uintptr_t), as obs-output.c.h already does at lines 366 and 394, so -Wcast-qual stays quiet.

@zackees
zackees added this pull request to the merge queue Oct 24, 2026
Merged via the queue into master with commit a6723d9 Oct 24, 2026
31 checks passed
@zackees
zackees deleted the fix/output-end-capture-thread-join 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.

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

1 participant