Skip to content

bug: libobs/frontend: two quick StartStream requests over obs-websocket crash OBS (upstream obsproject/obs-studio#13283) #538

Closed

Description

@rdoupe

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.cpp StartStream refuses only when obs_frontend_streaming_active(), which turns true once the stream has connected. A second request while the first is still connecting is accepted and queues another OBSBasic::StartStreaming().
  • frontend/widgets/OBSBasic_Streaming.cpp OBSBasic::StartStreaming() returns early only when outputHandler->StreamingActive() (obs_output_active(), false until connected). The Start Streaming hotkey also checks streamingStarting; the API path does not. So the second call sets the outputs up again under the connecting stream and calls obs_output_start() again.
  • libobs/obs-output.c obs_output_start() has no check for a start in progress, so it runs the output's start() again. plugins/obs-outputs/rtmp-stream.c rtmp_stream_start() then creates a second connect_thread on 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 StartStream twice 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() or obs_output_start() on the stream output while it is still connecting (obs-websocket StartOutput, 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 (its starting flag), 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 on StreamingPreparing), 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.

Activity

  1. rdoupe commented on Oct 13, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_output_start_twice (4 cases) registers an output that connects like rtmp_output: a second obs_output_start() while the first start is still in progress runs start() again (in OBS, a second RTMP connect thread on the same stream, the crash). 2 of 4 fail today.
    2. GREEN: obs_output_start() refuses an output that is still starting, and OBSBasic::StartStreaming() ignores a start while the stream is being prepared or connecting.
      PR today.
  2. added a commit that references this issue on Oct 13, 2026
    462a70d
  3. rdoupe commented on Oct 13, 2026

    @rdoupe
    CollaboratorAuthor

    @Dustinhoefer you reported this in obsproject/obs-studio#13283 (calling StartStream over 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 StartStream once 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-back StartStream requests 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 the StreamStateChanged event with OBS_WEBSOCKET_OUTPUT_STARTED (or check GetStreamStatus) 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-git in 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions