Skip to content

fix(source): read the show/activate ref counts atomically - #2083

Merged
zackees merged 1 commit into
masterfrom
fix/source-refs-atomic-reads
Oct 24, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/source-refs-atomic-reads

Conversation

@zackees

@zackees zackees commented Oct 24, 2026

Copy link
Copy Markdown
Member

Fixes #2081

activate_refs and show_refs are changed with os_atomic_inc_long/dec from the UI and graphics threads, but they were read as plain fields: in obs_source_active/obs_source_showing (called on the audio thread in audio_callback), in the video tick (now_showing/now_active), and in the add/remove-active-child loops. All six reads now use os_atomic_load_long. The loops take one snapshot of both counts, so they iterate over consistent values.

RED: TSan run 40066620813 on master has about 150 data-race reports at obs-source.c.h:4834, 1409 and 1432 against threading-posix.h:21/26, in 16+ tests. A data race fails deterministically only under TSan, so there is no Tier 2 RED; GREEN is a TSan run on this branch, linked below. Behavior is unchanged, and Tier 2 in PR CI covers that. ./lint passes. Tiers 1 and 3 don't apply: obs-source has no Rust port.

@zackees
zackees enabled auto-merge October 24, 2026 07:24
@zackees

zackees commented Oct 24, 2026

Copy link
Copy Markdown
Member Author

@zackees
zackees added this pull request to the merge queue Oct 24, 2026
Merged via the queue into master with commit 25e61b2 Oct 24, 2026
33 checks passed
@zackees

zackees commented Oct 24, 2026

Copy link
Copy Markdown
Member Author

GREEN: TSan run 40074021014 on this branch has 0 data-race summaries in obs_source_active/obs_source_showing (master run 40066620813: 49). Race sides in obs_source_video_tick dropped from 88 to 1.

chriscoveries pushed a commit to chriscoveries/obsrust-fork that referenced this pull request Oct 24, 2026
…#2106)

obs_source_remove sets source->removed on the UI thread while the render
threads read it (obs_source_removed, obs_view_source_removed, scene add).
Make it volatile and use os_atomic_load_bool/os_atomic_set_bool, as
obs-rust#2083 did for activate_refs and show_refs.

Fixes obs-rust#2105
@zackees
zackees deleted the fix/source-refs-atomic-reads 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: source show/activate ref counts are read without atomics (TSan, ~150 reports)

1 participant