Skip to content

libobs: stop signal after end_data_capture_thread starts reads a freed encoder last_error #2098

Closed

Description

@zackees

Follow-up of #2086/#2087, which fixed the not-active path. The active path in obs_output_end_data_capture_internal (libobs/obs-output.c.h) has the same order: it creates end_data_capture_thread and then calls signal_stop(output).

signal_stop → stop_params_init → obs_output_get_last_error returns vencoder->last_error_message unlocked. Meanwhile the thread runs stop_video_encoders → obs_encoder_stop → remove_connection → obs_encoder_shutdown → obs_encoder_set_last_error(NULL), which bfrees that string. The stop signal can therefore copy freed memory.

Evidence: TSan run 40074741825 (master with #2087 merged) still has about 108 obs-encoder.c.h:2231 reports against obs-output.c.h:2732, e.g. in test_replay_buffer_pause_stop: write in end_data_capture_thread, read in signal_stop from obs_output_end_data_capture_internal:2423.

Fix: build the stop params before pthread_create and emit them afterwards, as #2087 did. Only trusted local code can trigger this (low risk).

Activity

  1. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Claiming: this issue. Same split as #2087 on the active path; GREEN is a TSan run on the branch.

  2. added
    bug
    on Oct 24, 2026
  3. added
    claimed
    on Oct 24, 2026
  4. 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

    bugclaimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions