Skip to content

libobs, plugins: Callers ignore os_event_init failures and then use the event #2164

Closed

Description

@rdoupe

Bug

Several callers ignore what os_event_init() (and in one case pthread_mutex_init()/pthread_create()) returns, and then use the event. Before #2163, a failed init returned 0 anyway and left a zeroed lock, which happens to work on glibc. With #2163, a failed init returns an error and leaves the event pointer NULL, so these callers would crash on the first wait or signal instead of carrying on.

The inits don't fail on glibc with default attributes, so this is about failing cleanly under resource exhaustion, not a crash anyone sees today.

Callers found by the #2152 survey:

  • libobs/obs.c.h: obs_queue_task() when it waits, and obs_wait_for_destroy_queue();
  • libobs/util/buffered-file-serializer.c.h, which also ignores pthread_mutex_init and pthread_create;
  • libobs/util/platform-nix-inhibit.c.h: the create path, where a NULL event is already handled later;
  • plugins: mac-capture (several), obs-browser, ffmpeg-mux, and rtmp-services' ingest refresh wait.

Plan

  1. RED: extend test_pthread_init_failures (from libobs: Check pthread init and thread start results with != 0 #2163) with a failing os_event_init on each libobs caller. Check it returns or fails cleanly with no crash or leak.
  2. GREEN: check the result in each libobs caller and fail cleanly.
    • obs_queue_task: run the task inline or return without waiting, whichever matches its contract.
    • The serializer: fail its open.
    • Every successful path stays unchanged.
  3. Plugins: the same in each listed plugin, mostly one-line checks that fail the create. Plugins without a cmocka harness are verified by reading and by the platform builds.

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