Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obs_scene_find_source race condition/possible use-after-free #11648

Open
gottagofaster236 opened this issue Dec 20, 2024 · 0 comments
Open

obs_scene_find_source race condition/possible use-after-free #11648

gottagofaster236 opened this issue Dec 20, 2024 · 0 comments

Comments

@gottagofaster236
Copy link
Contributor

gottagofaster236 commented Dec 20, 2024

Operating System Info

Other

Other OS

No response

OBS Studio Version

31.0.0

OBS Studio Version (Other)

No response

OBS Studio Log URL

N/A

OBS Studio Crash Log URL

No response

Expected Behavior

There should be a way to call obs_scene_find_source and retain the reference to the sceneitem without a race condition

Current Behavior

obs_sceneitem_t *sceneitem = obs_scene_find_source(scene, "source");
// sceneitem can be freed by another thread between these two lines!
sceneitem = obs_sceneitem_addref(sceneitem);
if (!sceneitem) return;
// Do some work with the scene item
obs_sceneitem_release(sceneitem);

Steps to Reproduce

  1. Launch a thread calls to obs_scene_find_source and then tries to retain the reference (in a loop)
  2. Launch another thread that creates and deletes an item from a scene (in a loop)
  3. Eventually obs_sceneitem_addref will try to increase the reference on an already-freed source corresponding to the (freed) sceneitem

Anything else we should know?

Very low probability of triggering, but still would be nice to have a version of this function that actually increments the reference under a mutex before returning

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

No branches or pull requests

1 participant