Skip to content

Fix memory manager data races - a follow up fix - #1794

Merged
summeroff merged 5 commits into
stagingfrom
fix-memory-manager-data-races-2
Sep 30, 2026
Merged

summeroff merged 5 commits into
stagingfrom
fix-memory-manager-data-races-2

Conversation

@aleksandr-voitenko

@aleksandr-voitenko aleksandr-voitenko commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Add a scoped settings-update guard around Source::Update and Source::GetProperties, including property callbacks. The guard invalidates existing work before settings change and delays queries until all updates finish and an OBS source-update phase has passed. Delayed queries remain cancellable without consuming readiness retries or blocking other sources.

Add six regression cases covering deferred updates, overlapping updates, stale query results, property callbacks, source registration identity, and shutdown. Extend graphics-reset coverage and document the update timing and guard lifetime.

Motivation and Context

Changing a media file updates its settings before OBS applies the deferred plugin update. During that interval, the cache manager can associate the new filename with the previous player's metadata and enable caching with an incorrect memory reservation.

How Has This Been Tested?

Tests, Windows only.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

@aleksandr-voitenko
aleksandr-voitenko force-pushed the fix-memory-manager-data-races-2 branch from 104ee1b to 61bda66 Compare September 29, 2026 20:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

A cache-setting job can still overlap a guarded file change and enable caching using a stale reservation.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Adds guarded source-setting updates to prevent stale media metadata from corrupting cache reservations.

Changes:

  • Introduces scoped settings-update guards and deferred cache queries.
  • Applies guards to source updates and property callbacks.
  • Adds regression tests and API timing documentation.
File Description
obs-studio-server/​source/​memory-manager.cpp Implements guard tracking and delayed graphics queries.
obs-studio-server/​source/​memory-manager.h Defines the guard API and lifecycle contract.
obs-studio-server/​source/​osn-source.cpp Guards source update entry points.
obs-studio-server/​tests/​test-memory-manager.cpp Adds settings-race and reset coverage.
js/​module.ts Documents asynchronous video-source updates.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread obs-studio-server/source/memory-manager.cpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Partial source updates can still carry a stale cache enable into a newly selected media file.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread obs-studio-server/source/memory-manager.cpp
@summeroff
summeroff merged commit f7fc712 into staging Sep 30, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants