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-ffmpeg: Fix deadlock on shutting down muxer #10597

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

exeldro
Copy link
Contributor

@exeldro exeldro commented Apr 25, 2024

Description

The things that happen to get this deadlock:

  • the io thread reads shutdown_requested as false
  • the main thread sets shutdown_requested to true
  • the main thread gets the data_mutex
  • the main thread signals new_data_available_event
  • the main thread releases the data_mutex
  • the main thread waits for the io thread to exit
  • the io thread gets the data_mutex
  • the io thread resets new_data_available_event because chunk_used < 65536 && !shutting_down
  • the io thread releases the data_mutex
  • the io thread waits for new_data_available_event

with the changes the new_data_available_event cannot be send from the main thread between the reading of shutdown_requested the getting of the data_mutex in the io thread

Motivation and Context

Got a memory dump Fenrir from a muxer that was stuck.
the main thread is in ffmpeg_mux_free waiting for the io thread to close.
the io thread is waiting for new_data_available_event

How Has This Been Tested?

Muxer still works as expected

Types of changes

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

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@WizardCM WizardCM added Bug Fix Non-breaking change which fixes an issue Seeking Testers Build artifacts on CI labels Apr 27, 2024
@derrod derrod mentioned this pull request Apr 28, 2024
6 tasks
@derrod derrod requested a review from notr1ch April 28, 2024 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Non-breaking change which fixes an issue Seeking Testers Build artifacts on CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants