Repository navigation
Description
Upstream OBS bug, reported by Dustinhoefer in obsproject/obs-studio#13283 (OBS 32.1.0 on Ubuntu 24.04: calling StartStream over obs-websocket twice in a short period crashes OBS). Still crashes in this fork.
Location
plugins/obs-websocket/src/requesthandler/RequestHandler_Stream.cppStartStreamrefuses only whenobs_frontend_streaming_active(), which turns true once the stream has connected. A second request while the first is still connecting is accepted and queues anotherOBSBasic::StartStreaming().frontend/widgets/OBSBasic_Streaming.cppOBSBasic::StartStreaming()returns early only whenoutputHandler->StreamingActive()(obs_output_active(), false until connected). The Start Streaming hotkey also checksstreamingStarting; the API path does not. So the second call sets the outputs up again under the connecting stream and callsobs_output_start()again.libobs/obs-output.cobs_output_start()has no check for a start in progress, so it runs the output'sstart()again.plugins/obs-outputs/rtmp-stream.crtmp_stream_start()then creates a secondconnect_threadon the same stream while the first one is still running.
Class
Crash (SIGSEGV, heap corruption from two connect threads on one stream).
How it is reached
- obs-websocket
StartStreamtwice in quick succession (two requests, or a batch), from any remote control or deck button pressed twice. - Anything else that calls
obs_frontend_streaming_start()orobs_output_start()on the stream output while it is still connecting (obs-websocketStartOutput, scripts).
Reproduced in the current release
AppImage 33.0.0-beta6-799, headless, Simple output mode (x264), custom RTMP server on a local port with nothing listening, two StartStream requests sent back to back over obs-websocket: both return success, two StreamStateChanged STARTING events arrive, the log shows "Connecting to RTMP URL" twice and "Cannot apply a new video_t object after the encoder has been initialized", and OBS crashes with SIGSEGV in 3 of 5 runs. Backtrace (crashing thread "rtmp-stream: connect"):
#0 calloc () from libc.so.6
#1 ?? () from libmbedx509.so.7
#2 mbedtls_x509_crt_parse () from libmbedx509.so.7
#3 mbedtls_x509_crt_parse_file () from libmbedx509.so.7
#4 mbedtls_x509_crt_parse_path () from libmbedx509.so.7
#5 connect_thread () from obs-outputs.so
With the two requests sent one after the other (waiting for each answer), both are still accepted and both start the output (two STARTING events); no crash in that run.
Proposed fix and failing test
Fix:
obs_output_start()refuses an output whose start is still in progress (itsstartingflag), with a warning; delayed outputs keep their own restart handling.OBSBasic::StartStreaming()also returns while a stream is being prepared or connecting (streamingStarting, now also set onStreamingPreparing), as the hotkey already did, so a second request changes nothing and shows no error dialog.
RED test (cmocka, test_output_start_twice). It registers an output that behaves like rtmp_output while it connects (start() returns true without beginning data capture):
- a second start while the first is in progress must not run
start()again; - five more starts likewise;
- guard: after a failed connection the output starts again;
- guard: after a forced stop the output starts again.
The first two fail today in both libobs lanes, every run.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 13, 2026
Claiming: this issue.
test_output_start_twice(4 cases) registers an output that connects likertmp_output: a secondobs_output_start()while the first start is still in progress runsstart()again (in OBS, a second RTMP connect thread on the same stream, the crash). 2 of 4 fail today.obs_output_start()refuses an output that is still starting, andOBSBasic::StartStreaming()ignores a start while the stream is being prepared or connecting.PR today.
libobs, frontend: Don't start a stream that is still starting
rdoupe commentedon Oct 13, 2026
@Dustinhoefer you reported this in obsproject/obs-studio#13283 (calling
StartStreamover obs-websocket twice in a short period crashes OBS), so a heads-up: it's fixed here in obs-rust by #539, with a regression test.Cause: OBS only refused a second
StartStreamonce the first had connected. While the stream was still connecting, a second request started the RTMP output again, so two connect threads ran on one stream and corrupted its memory. In the obs-rust release, two back-to-backStartStreamrequests to a server that doesn't answer crashed OBS in 3 of 5 runs, in the RTMP connect thread. Now both libobs and the frontend refuse to start a stream that is still starting: the second request is ignored and the first connect carries on. With the fix the same test ran 5 of 5 times without a crash.Workaround on stock OBS: after
StartStream, wait for theStreamStateChangedevent withOBS_WEBSOCKET_OUTPUT_STARTED(or checkGetStreamStatus) before sending another start.It will be in the next obs-rust daily release after 0.1.0-beta.20261012: https://github.com/obs-rust/obs-studio/releases (Windows, macOS and Linux builds; on Arch it's
obs-studio-rust-gitin the AUR). obs-rust is an AI-assisted fork of OBS.If you get a chance to try it, a reply here on whether double starts still crash would really help.
libobs, frontend: Don't start a stream that is still starting (obs-ru…