Skip to content

bug: libobs/util: process-pipe destruction can lose waitpid errors #500

Closed

Description

@ProtonDev-sys

Location

libobs/util/pipe-posix.c:148-161, os_process_pipe_destroy:

int status;
do {
    ret = waitpid(pp->pid, &status, 0);
} while (ret == -1 && errno == EINTR);
if (WIFEXITED(status))
    ret = (int)(char)WEXITSTATUS(status);

Class

Uninitialized read / incorrect error reporting.

How it is reached

On POSIX, waitpid can fail without providing a valid child status. One reproducible Linux path is setting SIGCHLD to SIG_IGN, allowing the kernel to auto-reap the process-pipe child. waitpid then returns -1 with ECHILD, but destroy still evaluates the uninitialized status slot and can overwrite the error with an apparent successful exit code.

This report is based on the existing fork branch ProtonDev-sys/obs-studio:fix/pipe-wait-error. The branch author reports the original source also fails an unwrapped Linux probe compiled with automatic-variable zero initialization. The submitting agent inspected the implementation and regression diff but has not independently rerun that probe. No upstream OBS issue is known from this submission.

Proposed fix and failing test

Only decode status when waitpid succeeded: guard WIFEXITED(status) with ret != -1, preserving the existing retry on EINTR and returning -1 on permanent wait failure.

The regression compiles the real process-pipe implementation with a waitpid wrapper. The wrapper seeds the status slot to zero to make an invalid read observable; the real Linux kernel produces ECHILD under SIGCHLD=SIG_IGN. Add controls for a normal exit of 23 and retry after one EINTR.

  • RED commit 0831d51e4af6bbe24a06e282a60be8407d1f01ce: the author reports destroy returns 0 instead of -1 on the auto-reaped-child case; normal exit and EINTR controls pass.
  • GREEN commit 6266a29a0f4d6d2a54439303d208194ec50eaf28: the author reports all three cases pass with GCC and Clang, including 100 ASan/UBSan/LSan runs, and reverting the condition restores the failure.

The full OBS gate and other platforms remain untested; the accompanying PR will be a draft. The fork author could not file the upstream issue through the connector, so this report is being filed before submitting their existing branch.

AI assistance: branch commits credit gpt-6-astra-pro; Codex inspected and submitted the report on the account owner's request.

Activity

  1. ProtonDev-sys commented on Oct 13, 2026

    @ProtonDev-sys
    ContributorAuthor

    Claiming: process-pipe wait-error reporting in libobs/util/pipe-posix.c.

    1. Submit the existing fork branch ProtonDev-sys:fix/pipe-wait-error with its RED then GREEN commits as one draft PR to master.
    2. Preserve the branch author's regression evidence and disclose that the full OBS local gate and non-Linux validation remain outstanding.

    Expected first PR: now. The implementation already existed in the fork because the author could not file upstream through the connector. A maintainer may add the claimed label; the draft PR will make the work visible immediately.

  2. added
    claimed
    on Oct 13, 2026
  3. zackees commented on Oct 13, 2026

    @zackees
    Member

    Fixed by #501. C now matches the Rust port, which already returned -1 when waitpid fails.

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