Repository navigation
Fix hang on OBS exit caused by use-after-free in destroy path - #174
Conversation
source_record_filter_destroy queued force_stop_output_task via run_queued and then called source_record_delayed_destroy directly, which could free the context before the queued tasks ran. During OBS exit the task queue often stops processing before the queued stops fire, leaving outputs in a stopping state that OBS waits on, causing the entire application to hang on close. Introduce stop_output_sync() which force-stops and releases an output inline (after disconnecting the remove_filter signal), and use it in all closing paths: filter_remove, destroy, and the closing branches of filter_update. The non-closing stop paths (user-initiated toggle off, tick restart/disable) still use the async force_stop_output_task path. delayed_destroy is removed and its cleanup logic inlined into destroy.
|
With these changes I get a crash when I try to close OBS, switch scene collection or remove the filter when replay buffer on source record is active. The source record was on the active scene. |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Pushed a fix. Tested on OBS 32.1.1 with replay buffer active — close OBS, switch scene collection, remove filter. No crash, no hang. What OBS version are you building against? |
|
I test on OBS 32.1.1 |
obs_output_force_stop is async for encoded outputs; releasing immediately races with end_data_capture_thread still using encoders. Let destroy handle release after encoder inactivity poll. Fixes crash on filter remove and scene collection switch with replay buffer active. Fixes output reference leak on exit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The code seems to work now, I plan to do a code review in the next days |
|
Thanks. The last commit ( Thanks for the plugin btw, we use it all the time. |
source_record_filter_destroyqueuedforce_stop_output_taskviarun_queuedand then calledsource_record_delayed_destroydirectly,which could free the context before the queued tasks ran. On OBS exit
the queue often stops processing before those tasks fire, leaving
outputs in a stopping state that OBS waits on — causing the hang.
Introduces
stop_output_sync()which force-stops and releases anoutput inline, and uses it in the closing paths (
filter_remove,destroy, and the closing branches offilter_update). Non-closingstops (toggle-off, tick restart/disable) keep the async path.
delayed_destroyis removed and its cleanup inlined intodestroy.