Skip to content

libobs: stop signal still races a previous stop's encoder shutdown on last_error #2110

Closed

Description

@zackees

Follow-up of #2086/#2098 (#2087, #2100). After those fixes, TSan run 40078572852 still has 7 obs_encoder_set_last_error (obs-encoder.c.h:2231) reports against obs_output_get_last_error (obs-output.c.h:2738), in test_encoding_lag_rescale and one other test.

The case: a stop on the not-active path (obs_output_end_data_capture_internal:2374, here from obs_output_destroy → obs_output_actual_stop) builds the stop params while the previous stop's end_data_capture_thread is still running stop_video_encoders → obs_encoder_shutdown, which frees the encoder's last_error_message. That path deliberately doesn't join a running thread ("this never waits"). Reordering can't fix it.

Options:

  1. In stop_params_init, copy the encoder's message under the mutex obs_encoder_set_last_error runs under. Check lock order against obs_encoder_shutdown's callers first.
  2. Give last_error_message its own small mutex, and have internal readers copy under it.

The public obs_encoder_get_last_error/obs_output_get_last_error return a borrowed pointer, so external callers keep upstream's contract either way. Low risk (local).

Activity

  1. added
    bug
    on Oct 24, 2026
  2. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Claiming: this issue.

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