obsproject / obsproject/obs-studio
crash report about using freed video_t
@RytoEX is already working on this.
Since May 30, 2025.
- Dominant language
- C
- Stars
- 76.4k
- Forks
- 10.2k
- Avg merge
- 4d 23h
- Merged PRs (30d)
- 12
Description
Operating System Info
Windows 11
Other OS
No response
OBS Studio Version
31.0.3
OBS Studio Version (Other)
debugging code of obs 31.0.3
OBS Studio Log URL
I have attched log file
OBS Studio Crash Log URL
No response
Expected Behavior
no crash
Current Behavior
crashed
During debugging code of obs-31.0.3, this crash can be reproduced easiy;
During running released packet of obs-31.0.3, this crash can be reproduced sometimes (because accessing deleted memory will not cause crash often in release mode).
Steps to Reproduce
- settings dialog -> Advanced -> IP Family -> select "
IPV6 Only" (in fact, I have no ipv6. This is only for causing connect failture) - settings dialog -> Stream -> select any platform and input streamkey
- settings dialog -> Output-> advanced mode -> Streaming -> select x264 encoder
- click "start streaming", alert appeared with "
Failed to connect to server"
- settings dialog -> Video -> only change "Output Resolution"
- click "start streaming" again, crash happen!
Anything else we should know?
log file during running released obs-31.0.3:
2025-05-27 10-02-58.txt
crash callstack during debugging:
My Analysis Conclusion
- In step-4,
obs_output_signal_stopis called andobs_output_end_data_capture_internalwill return directly without creatingend_data_capture_thread.
compared with normal stop of streaming, in this situation, obs_encoder_shutdown will not be called.
-
in step-5,
obs_reset_videois called and all old video_t will be freed.
however,BasicOutputHandleris not re-created -
in step-6, callstack in BasicOutputHandler is as below (as the crash callstack):
AdvancedOutput::SetupStreaming -> AdvancedOutput::UpdateStreamSettings -> obs_encoder_update -> obs_x264_update -> obs_encoder_get_width -> get_const_root(video_t*)
however, now the video_t is freed in step-5. then crashed!
- For normal stop of steam,
obs_encoder_shutdownwill be called andobs_encoder::context.datawill be set with NULL.
So in step-4, obs_encoder_update will return as below:
after that for nomal stop of stream, the new video_t will be set to encoder by obs_encoder_set_video before obs_output_start
Solution?
metho-1
modify OBSBasicSettings::SaveSettings().
BasicOutputHandler should always be re-created if obs_reset_video is called and it should be called after obs_reset_video.
AS-IS
TO-BE
metho-2
in obs_output_end_data_capture_internal, if it is not a normal stop of stream, should we clear any variable before returning ?
But as my understand, end_data_capture must be paired with hook_data_capture. In this crash, hook_data_capture has not been called because RTMP failed to connect server
Since the impact of my two methods is relatively large. I paste they here for talking about.
Maybe they are not right~
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.