Skip to content

libobs: stop signal reads encoder last_error while the unstarted-encoder shutdown thread frees it #2086

Closed

Description

@zackees

TSan (run 40066620813): 46 reports in 14 tests, obs-encoder.c.h:2231 (obs_encoder_set_last_error) against obs-output.c.h:2706 (obs_output_get_last_error).

When an output stops before its data capture began, obs_output_end_data_capture_internal starts shutdown_unstarted_encoders_thread, then calls signal_stop(). signal_stop() reads the encoders' last_error_message for the stop signal. The new thread runs obs_encoder_shutdown → obs_encoder_set_last_error(encoder, NULL), which frees that string, so the read can land on freed memory.

Fix: copy the stop signal's parameters (including last_error) before starting the thread, and emit them afterwards. The thread order stays the same, so a stop handler that restarts the output still waits for the shutdown.

Activity

  1. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Claiming: build the stop calldata before the shutdown thread starts. PR today.

  2. added
    claimed
    on Oct 24, 2026
  3. added a commit that references this issue on Oct 27, 2026
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

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions