Skip to content

Flaky Tier 2: test_source_transition_slots clear_empties_both_slots child_alive under load #4680

Closed

Description

@zackees

test_source_transition_slots / clear_empties_both_slots fails intermittently on clean master against the hybrid libobs.

It looks like a timing race: the child source is released asynchronously (for example via the destruction task or the video thread) after the transition clears its slots, and the test checks the child before release finishes under load. Fix it in the Rust/C implementation or by deterministic synchronization in libobs. Don't edit the existing C test.

Evidence and launchers: the pool's fix-4672b report (focused.py, stress.py, master-lane3.log, master-lane4.log).

🤖 Generated with Claude Code

Activity

  1. added
    bug
    on Nov 11, 2026
  2. vpacher commented on Nov 13, 2026

    @vpacher
    Member

    /ready
    Coordinator triage. The reproduction is concrete: 4 parallel ctest --repeat until-fail:250 lanes in a 4-CPU Docker task fail at about repeat 41, and a hosted run failed the same way.

    Acceptance: the unchanged test passes the same parallel repeat against both hybrid libobs and the C reference. Commit the RED evidence first, then the deterministic fix. Do not edit test_source_transition_slots.c (AGENTS.md: existing C tests stay unchanged).

    #4800 may share the same asynchronous release path. Check it in the same investigation.

  3. added
    ready
    P2
    size:M
    on Nov 13, 2026
  4. rdoupe commented on Nov 14, 2026

    @rdoupe
    Collaborator

    Could not reproduce on today's master (2026-11-14), so I'm not claiming this.

    What I tried, on a 16-thread Ryzen 9 6900HX, with RelWithDebInfo builds of both libobs variants (hybrid Rust and C reference) from today's master. Each lane runs the unchanged test_source_transition_slots binary in a loop with ctest's environment (LP_NUM_THREADS=1, the rundir as working directory), on its own Xvfb display, and stops at the first failure:

    libobs load runs failures
    C reference 16 parallel lanes × 150 2400 0
    hybrid 16 parallel lanes × 150 2400 0
    hybrid 8 lanes pinned to 2 CPUs (taskset -c 0-1) × 100 800 0
    hybrid 6 lanes × 80 on 2 CPUs, plus 4 busy-loop hogs on the same CPUs 480 0

    (A first attempt with xvfb-run -a in parallel "failed" on rep 1 in most lanes; that was xvfb-run lanes racing for display numbers, not the test. Separate Xvfb displays fixed it.)

    One candidate for the window, not confirmed: tick_sources() (libobs/obs-video.c.h:47-66) takes a reference on every non-removed source in data->sources, private ones included, ticks them, then releases. If obs_transition_clear() drops the test's last references while the video thread is between that obs_source_get_ref() and its obs_source_release(), the weak reference still gives the source and child_alive() is true. That code is the same in both variants, and the C reference didn't fail here either. So if this is the cause, it's a test-timing race and not a Rust regression, and the fix would be a decision about the test (which AGENTS.md says not to edit) or about upstream tick semantics, not a libobs port fix.

    Someone with the original Docker setup (4 lanes in a 4-CPU task) is better placed to reproduce it.

  5. zackees commented on Nov 18, 2026

    @zackees
    MemberAuthor

    Claiming: investigation and fix for transition-slot lifetime flake on branch fix/4680-transition-slot-lifetime.

    1. Measure recent merge-group hits and repeat the unchanged suite in four parallel lanes sharing four CPUs on current master, against hybrid and C reference.
    2. Trace source references and distinguish an implementation race from test assumptions; add deterministic Rust regression coverage for any implementation fix. Use a CTest resource lock only with demonstrated cross-test interference.
    3. Commit RED evidence then GREEN, run ./lint once, and publish a PR with Refs Flaky Tier 2: test_source_transition_slots clear_empties_both_slots child_alive under load #4680 if a justified fix is found. First PR expected in this worker session; otherwise report exact NO-REPRO counts to the pool.
  6. zackees commented on Nov 18, 2026

    @zackees
    MemberAuthor

    #5054 merged at 08:23Z: this test is now in test/cmocka/known-flaky.txt, so a merge-queue run whose ONLY failures are registered tests retries them once and passes with a ::warning:: (and a step-summary line) instead of ejecting the group. This shields the queue; it does not resolve the root cause, so this issue stays open. Remove the registry line in the PR that fixes it.

  7. moved this from Ready to In progress in obs-rust Multiviewon Nov 18, 2026
  8. moved this from In progress to Ready in obs-rust Multiviewon Nov 19, 2026
  9. rdoupe commented on Nov 21, 2026

    @rdoupe
    Collaborator

    Decision needed: may I add one line to test/cmocka/test_source_transition_slots.c to fix this flake? AGENTS.md says existing C tests stay unchanged, so this needs your yes.

    I reproduced it on demand against the C reference with two local-only delays (neither would be committed): 30 ms in tick_sources() right after it takes its source references (libobs/obs-video.c.h), and 40 ms in clear_empties_both_slots before obs_transition_clear(), so a tick is sure to pick the children up first:

    OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 3 --tests test_source_transition_slots
    [OFF] tests load /build/tree/libobs-c-reference/libobs.so.30
    [  ERROR   ] --- child_alive(0) is not false
    [   LINE   ] --- /ro/test/cmocka/test_source_transition_slots.c:246: error: Failure!
    

    (That's line 245 without the added delay line, which is the failure in this issue.)

    Cause: tick_sources() holds its own reference on every source while it ticks, and the video thread releases it after obs_transition_clear() has already dropped the transition's references, so the weak reference still gives the child for a moment. The C reference does the same thing, and this is how upstream libobs works, not a port bug. Changing the tick to stop holding references would differ from upstream and risk deadlocks, so I don't recommend fixing it in libobs.

    Proposed fix: child_alive() calls obs_wait_for_destroy_queue() before it checks the weak reference. Since #5407 that waits for a video tick even when no audio is running (this fixture only resets video), which is the same wait that fixed #4800 in test_transition_load_release. With both delays still in place and that one line added, the test passes against the C reference.

    If you say yes, I'll claim this and open one PR: that line plus removing the test's line from known-flaky.txt, with the RED run above and the GREEN run in the body.

  10. added
    decision-needed
    on Nov 21, 2026
  11. moved this from Ready to Needs decision in obs-rust Multiviewon Nov 21, 2026
  12. zackees commented on Nov 21, 2026

    @zackees
    MemberAuthor

    Decided: yes, add the obs_wait_for_destroy_queue() call to child_alive() in test/cmocka/test_source_transition_slots.c, and in the same PR remove the test's line from test/cmocka/known-flaky.txt.

    Reasons:

    Conditions for the PR: change no assertion and remove none; add only the wait. Put the C-reference RED (the two local delays, not committed) and the GREEN in the body, plus rust/tools/linux-validate/run.py --repeat 100 --tests test_source_transition_slots passing in both the OFF and ON builds. Refs #4680 (Fixes once it is green). rdoupe, go ahead and claim it.

  13. removed
    decision-needed
    on Nov 21, 2026
  14. moved this from Needs decision to Ready in obs-rust Multiviewon Nov 21, 2026
  15. rdoupe commented on Nov 21, 2026

    @rdoupe
    Collaborator

    Claiming: the approved one-line wait in child_alive() plus dropping the test from known-flaky.txt, on branch fix/4680-transition-slot-wait.

  16. added a commit that references this issue on Nov 23, 2026
    ea7fef2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2bugreadysize:M

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions