Skip to content

bug: test: align_divisor_restarts_the_phase races video_output_stop and reddens the Fast Gate on ~30% of runs #2957

Closed

Description

@zackees

Location

rust/obs-media-io/tests/video/video_io.rs:539-600 — align_divisor_restarts_the_phase, added by #2926, together with the harness helper Session::wait_hits (lines 83-88):

        for stamp in stamps[1..].iter() {
            push(*stamp);
        }
    }
    session.wait_hits(2);
    unsafe { video_output_stop(video) };
    ...
    unsafe { assert_eq!(video_output_get_total_frames(video), 4) };

Class

Flaky test (test synchronization bug, not a port defect): the last queued frame races video_output_stop.

How it is reached

./unittest, and every PR's Build 🧱 / Fast Gate ⚡ lane, which runs the Tier 1 suite:

soldr cargo test -p obs-media-io --lib align_divisor_restarts_the_phase

On master 61c814e48: 18 of 60 runs fail, and 8 of 40 runs of the whole tests::video::video_io module fail, always the same way:

thread 'tests::video::video_io::align_divisor_restarts_the_phase' panicked at
rust/obs-media-io/tests/video/video_io.rs:600:14:
assertion `left == right` failed
  left: 3
 right: 4

Seen on CI: PR #2951, run 40936499568, job 123669886573, == test-diff: FAILED (exit 1) on a PR that touches no Rust code, so the failure is inherited from master and reddens unrelated PRs at random.

Cause: the test pushes 2000, 3000 and 4000 back to back, and wait_hits(2) returns the moment 3000 has been delivered — the 4000 push may still be sitting in the cache slot. video_output_stop then sets stop and the video thread breaks at its if shared.stop check before it takes that frame, so total is 3 instead of 4. C's video_output_stop has the same property (a queued frame at shutdown is dropped), so the assertion needs to wait for the frame to be processed, not just pushed. Nothing else in the module flakes: 40 runs of tests::video::video_io produced this one test and no other failure.

Proposed fix and failing test

Add a Session::settle(total: u32) helper that spins on video_output_get_total_frames (with a ~2 s deadline, panic! naming the value it saw) and call it before video_output_stop in align_divisor_restarts_the_phase, so the fourth frame gets its turn before the stop flag. Same file, same test binary, no new test target.

  • RED (today, master): align_divisor_restarts_the_phase fails 18/60 with left: 3, right: 4.
  • GREEN: 0 failures in 200 runs, and the assertion still fails if the frame is never processed (the settle deadline panics with the observed count).

Activity

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

    @zackees
    MemberAuthor

    Claiming: #2957 — the align_divisor_restarts_the_phase Fast Gate flake

    This is master breakage that reddens unrelated PRs (my #2951 failed its Fast Gate on it while touching only macOS frontend files), so I am taking it now.

    1. RED: record the local failure rate on master (soldr cargo test -p obs-media-io --lib align_divisor_restarts_the_phase, 60 runs, 18 failures, left: 3, right: 4).
    2. GREEN: add a Session::settle(total) helper in rust/obs-media-io/tests/video/video_io.rs that waits (bounded, ~2 s) for video_output_get_total_frames to reach the expected count before video_output_stop, and use it in the test; 200 runs clean.
    3. One PR, fix/2957-align-divisor-flake, Fixes #2957.

    First PR expected within the hour.

  3. added
    ready
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions