obs-studio
obs-studio copied to clipboard
libobs: Should not free audio_output before clearing view->channels
Description
When stop_audio() is called, view->channels has not been cleared yet, where maybe storage global output/input audio source.
So variables related with audio should not be deleted in stop_audio().
Motivation and Context
fix possible crash
How Has This Been Tested?
enable global desktop audio, exit OBS
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
- [x] My code has been run through clang-format.
- [x] I have read the contributing document.
- [x] My code is not on the master branch.
- [x] The code has been tested.
- [x] All commit messages are properly formatted and commits squashed where appropriate.
- [x] I have included updates to all appropriate documentation.
Are there reproduction steps for the fixed crash or is it just possible?
Are there reproduction steps for the fixed crash or is it just possible?
Just possible and I meet this crash once. Difficult to reproduce
Even if it's difficult to reproduce, could you describe how view->channels holds the global audio sources when entering obs_shutdown()? If there is a possibility to cause a crash, I think it is important to fix.
I've added a log message entering stop_audio... at the beginning of stop_audio() and entering obs_source_destroy... at the beginning of obs_source_destroy(). Then checked which is called earlier. On my run, obs_source_destroy() is called earlier.
My understanding is that obs_shutdown() is called after all sources are destroyed. And also obs_wait_for_destroy_queue() at the beginning of obs_shutdown() waits audio thread has exited.
Just in case a reference-count of a source is not correctly decremented, it is a memory leak rather than an invalid order of the shutdown.
view->channels
view->channels holds the reference of root source, and it is released in obs_main_view_free.
However, obs_main_view_free is called after stop_audio().
@norihiro
view->channelsholds the reference of root source, and it is released inobs_main_view_free. However,obs_main_view_freeis called afterstop_audio().
Before stop_audio, OBSBasic::ClearSceneData() should have released the main-views. The main-views should not be a concern.
https://github.com/obsproject/obs-studio/blob/b4f7499b33b53351e56a02fc6194f11d8af78da5/UI/window-basic-main.cpp#L4640-L4641
AFAIK, if script or third party plugins have not released a reference-count of an audio source, stop_audio() might fail. However I feel such a scenario is not a fault of the shutdown process but a memory leak.
view->channelsholds the reference of root source, and it is released inobs_main_view_free. However,obs_main_view_freeis called afterstop_audio().Before
stop_audio,OBSBasic::ClearSceneData()should have released the main-views. The main-views should not be a concern.https://github.com/obsproject/obs-studio/blob/b4f7499b33b53351e56a02fc6194f11d8af78da5/UI/window-basic-main.cpp#L4640-L4641
AFAIK, if script or third party plugins have not released a reference-count of an audio source,
stop_audio()might fail. However I feel such a scenario is not a fault of the shutdown process but a memory leak.
sorry to response late.
yes, this crash is because of another scenario that any source has not been released completely until stop_audio().
Now I agree with you to ignore this crash. I will close it. Thannks ~