Skip to content

test: test_screencast_portal_teardown hangs to its 20 s alarm now and then (Tier 2 ON, queue run 40076937467) #2099

Open

Description

@zackees

test_screencast_portal_teardown / reply_during_destroy_is_dropped hung until its 20 s alarm() in a merge-queue run and ejected #2091:

The forked child runs run_scenario() with alarm(20), so a 20.03 s failure is the alarm firing: the scenario hung (a portal reply during destroy never completing, or a wait on the private D-Bus/PipeWire that never returned), not a crash. The child's stderr does not say where it waited.

Next step: rerun the test with --repeat until-fail:50 under the CI load profile (./unittest --lane tier2-linux or validate.sh --repeat 50 --tests test_screencast_portal_teardown) to reproduce, and log the scenario's phases so a hang shows its last step. Related: #246 (the original crash this test covers).

Activity

  1. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Places in run_scenario() that can block past the 20 s alarm (from reading the test, not reproduced):

    • g_test_dbus_up(): waits for the private dbus-daemon to start.
    • portal_thread: g_dbus_connection_new_for_address_sync and RequestName via g_dbus_connection_call_sync(..., -1, ...) (no timeout); the main thread waits on os_event_wait(portal.ready) with no timeout, so a stuck bus hangs the child.
    • GDBus calls inside the screencast portal code use the default 25 s timeout, longer than the alarm.
    • obs_wait_for_destroy_queue() and obs_shutdown() after the capture is destroyed.
      The child's stderr shows nothing before the alarm, so the fix starts with logging the phase (PORTAL_TEST_VERBOSE already exists; a phase line before each of these would say which one).
  2. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Claiming: #2099. 1) reproduce with a repeated run of the test in the local Tier 2 container; 2) find which wait hangs; 3) fix the product code where it waits without a bound (the test itself is not edited, per policy). PR once reproduced.

  3. added
    claimed
    on Oct 24, 2026
  4. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Not reproduced locally: 100 runs idle and 400 under CPU load (both builds, run.sh --repeat) all passed, every run 1.8-1.95 s. So it's a rare race that sticks, not a slow wait. #2123 turns on the test's own PORTAL_TEST_VERBOSE in its registration so the next CI hang prints the last libobs step (or nothing, if it stuck in D-Bus/X setup). I'll keep this claim and take the fix once a failure log shows where.

  5. moved this from In progress to Triage in obs-rust Multiviewon Oct 25, 2026
  6. added
    ready
    and removed
    claimed
    on Oct 25, 2026
  7. moved this from Triage to In progress in obs-rust Multiviewon Oct 25, 2026
  8. zackees commented on Oct 25, 2026

    @zackees
    MemberAuthor

    Two more cases, both on PRs that don't touch linux-pipewire: reply_during_destroy_is_dropped failed at test_screencast_portal_teardown.c:330 in Tier 2 Linux on #2420 (run 40229295020, tests OFF) and on #2419 (run 40228403149, tests ON), minutes apart. Two in one hour suggests it's getting more frequent under load. I've re-run #2420.

  9. zackees commented on Oct 26, 2026

    @zackees
    MemberAuthor

    The first hang with PORTAL_TEST_VERBOSE on (#2123): #2419, run 40228403149, attempt 1, job 121276394469 (Tier 2 Linux, tests ON, a 2-core runner). The child's last libobs lines, in order:

    [pipewire] Screencast session created
    [pipewire] Response to select source received
    [pipewire] Asking for monitor and window
    Source 'capture' destroyed
    gs_enter_context: Null 'graphics' parameter
    gs_texture_destroy: called while not in a graphics context   (x18)
    gs_leave_context: called while not in a graphics context
    [portals] Request cancelled
    Cleaning up pid 2895                                           (GTestDBus watcher, after the alarm)
    

    After Request cancelled the child logs nothing until the alarm. obs_shutdown() logs its own lines, and none appear, so the child hung before obs_shutdown(). It was in the last iterate_main_loop(1500), in obs_wait_for_destroy_queue(), or in iterate_main_loop(200). The destroy thread had reached on_cancelled_cb() (the test's handler holds it there for 300 ms).

    Two things in the code to check first. Neither is confirmed.

    • [portals] Request cancelled was logged from a thread that is not the test's main thread, because the handler only acts on it when !on_main. The only cancel on the destroy path is free_capture(), and that is meant to run on the main loop through the finish_destroy idle source. That points at either on_cancelled_cb running on another thread, from a g_cancellable_connect() on an already-cancelled cancellable or from GDBus's worker, or the idle source being dispatched off the main thread. Either way, the cancel then runs alongside the main thread's reply handling, which capture_hold()/finish_destroy() are meant to prevent.
    • Since GLib 2.80, g_cancellable_cancel() emits cancelled with the cancellable's lock held. A main-thread callback that touches the same cancellable (g_cancellable_connect/disconnect, or g_dbus_proxy_call with it) while the destroy thread is inside on_cancelled_cb → portal_signal_call_free() → g_dbus_connection_signal_unsubscribe() can block in either order. A block in GDBus would then last up to its 25 s default timeout, which is longer than the 20 s alarm.

    A stack from the hung child would settle it. Before _exit, the test could have the alarm handler print gdb -batch -p <pid> -ex 'thread apply all bt', but the test can't be edited. The registration (as #2123 did for verbose) could instead run it under timeout -s QUIT 18 with core dumps on, and upload the core.

  10. zackees commented on Oct 26, 2026

    @zackees
    MemberAuthor

    Another hit of test_screencast_portal_teardown reply_during_destroy_is_dropped (test_screencast_portal_teardown.c:330) on #2503's Rust Tier 2 Linux (tests OFF), run 40365468404. The PR doesn't touch screencast code. I've rerun the failed jobs.

  11. 4 remaining items

  12. removed
    claim-blocked
    on Oct 27, 2026
  13. removed their assignment
    on Oct 28, 2026
  14. moved this from In progress to Ready in obs-rust Multiviewon Oct 28, 2026
  15. zackees commented on Oct 29, 2026

    @zackees
    MemberAuthor

    Reproduction-recipe correction, from the #456 tick today: the filter this issue recommends matches no test.

    validate.sh --repeat 50 --tests test_deinterlace_2x_field_order reaches CTest as ctest --repeat until-fail:50 -R 'test_deinterlace_2x_field_order' (unanchored, so that one does match) — but the anchored form used on 2026-10-27 and in this issue's text, '^test_deinterlace_2x_field_order$', matches nothing: CTest registers one test per case (test_deinterlace_2x_field_order_60i_into_60, _50i_into_50, _60i_into_50, _50i_into_30). A repeat run with the $ anchor prints No tests were found!!! and exits 0, i.e. it looks like a clean 50-rep pass while executing nothing.

    On the #456 evidence, the flake there is load-induced and hits first_frame_linear_2x_unbuffered_60i_into_60 at about 1 in 15 loaded reps on this host (12 hogs / 16 cores, Tier 2 libobs build), while 60 idle reps in both modes all passed.

    Unchanged in this issue: no new CI hang of reply_during_destroy_is_dropped has appeared — the last 40 workflow runs contain two failures, both verify_only app-lane dispatches, neither in a Tier 2 test job. The claim still waits on one hang that prints the #2553 teardown-phase lines.

  16. zackees commented on Oct 29, 2026

    @zackees
    MemberAuthor

    Claiming: #2099 (the intermittent 20 s alarm hang in test_screencast_portal_teardown).

    Plan, one PR:

    1. Reproduce under load with repeated runs and capture the child's last phase, so the hang names the wait it is stuck in.
    2. Fix the wait itself if the cause is in the test or the portal teardown path; otherwise keep the phase log so the next ejection explains itself.
    3. Record the run evidence in the PR; Refs, not Fixes, if the hang is not reproduced locally.

    Expect the first PR this tick.

  17. zackees commented on Oct 29, 2026

    @zackees
    MemberAuthor

    Blocked: still waiting for one CI hang that prints the #2553 teardown-phase lines. New evidence this tick, all negative:

    Plan unchanged: the first hang that prints [portals] Freeing a destroyed capture / Capture freed / Unloading names the phase, and the fix follows. I keep the claim.

  18. added
    claim-blocked
    on Oct 29, 2026
  19. removed
    claim-blocked
    on Nov 5, 2026
  20. zackees commented on Nov 12, 2026

    @zackees
    MemberAuthor

    Pool triage update: the teardown-phase instrumentation from #2553 has now caught the hang.

    On merged #4733, run 43087239914, attempt 1, tests ON, job 130764201153, the test fails after 20.03 s with SIGALRM (14). Its last product messages are Freeing a destroyed capture followed by Request cancelled; neither Capture freed nor the portal unload entry appears. This directly answers the evidence request in the previous blocked comments. The same test later passes in attempt 3 (1.74 s) and attempt 4 (1.76 s) on the same PR head.

    Seven-day audit, workflow creation window 2026-11-05 22:13:35 UTC through 2026-11-12 22:13:35 UTC:

    Event Enumerated workflows Failed jobs (affected runs)
    master push 450 2 (2)
    PR 1,172 6 (6)
    merge group 675 3 (3)

    Counts are failed Linux Tier 2 job executions, with distinct affected workflow runs in parentheses. Denominators count all enumerated workflows, including scoped/skipped/cancelled runs; they are not a per-test flake probability. I checked every recorded attempt of non-successful or retried runs, including attempts hidden behind a final green result. The audit retained 1,196 candidate attempt/job snapshots and read all 170 failed/timed-out or started-and-cancelled Linux Tier 2 test-job logs, with no unavailable selected logs. Two master workflows were incomplete in the initial run-list snapshot; counts describe observed failures in the fetched evidence. Reruns of workflows created before the window are outside this cohort.

    All 11 portal failures have SIGALRM 14 and the same two last teardown markers, without Capture freed. They span 7 OFF / 4 ON jobs. Complete failing-job index:

    Event Run / attempt Mode Job log
    merge group 42352203620 / 1 OFF job 128343489466
    merge group 42382595386 / 1 ON job 128435760394
    PR 42412770307 / 1 ON job 128530290467
    master push 42423067390 / 1 OFF job 128562350605
    merge group 42429816229 / 1 OFF job 128577439929
    PR 42455440003 / 1 OFF job 128655036025
    PR 42796830298 / 1 OFF job 129773928552
    PR 42932568086 / 1 OFF job 130237616089
    master push 42987628114 / 1 OFF job 130416851711
    PR 43003766533 / 1 ON job 130473239210
    PR 43087239914 / 1 ON job 130764201153

    Root-cause hypothesis: cancellation/D-Bus lock inversion. At the inspected master 7604fcc39075:

    • screencast-portal.c.h:1041 calls g_cancellable_cancel() from free_capture().
    • Its synchronous portal.c.h:139-151 cancellation handler logs the last observed message, sends a D-Bus Request.Close, and unsubscribes the response signal. Both D-Bus operations can take the connection lock.
    • The shipped build installs GLib 2.88.0-1ubuntu0.1. In GLib 2.88.0 gcancellable.c, cancellation emits handlers while holding the cancellable mutex. In gdbusconnection.c, the reply worker holds the connection lock through send_message_with_reply_cleanup(), which calls g_cancellable_disconnect() and takes the cancellable mutex. These paths permit cancellable → connection against connection → cancellable.

    This explains why an async D-Bus call inside the cancellation callback can still hang before the free-exit marker. It is a concrete source-level hypothesis, not a confirmed hung-process stack. The observed phase is after the PipeWire destroy calls and before completion of free_capture, so a PipeWire start/stop hang or a later obs_shutdown wait does not fit these particular logs.

    Next focused step: capture both threads' stacks before the unchanged child's 20 s alarm, then move Request.Close/unsubscribe cleanup out of synchronous cancellation emission while retaining capture/request state until deferred cleanup finishes. A focused new regression case should force reply cleanup to overlap cancellation. Do not replace the signal disconnect with g_cancellable_disconnect() inside its own cancelled handler: GLib explicitly documents that as a deadlock.

    No local reproduction attempted: this host had load averages 35.56/29.67/26.40 on 16 logical CPUs. No C tests, workflows, public headers, or product code were edited; no PR or push.

  21. rdoupe commented on Nov 23, 2026

    @rdoupe
    Collaborator

    Seen again on the master push of cb0d23e (#5523, a CI-only change): https://github.com/obs-rust/obs-studio/actions/runs/45244045417/job/137946925694 — reply_during_destroy_is_dropped hit the 20 s alarm (signal 14) right after [portals] Request cancelled. Reran the failed job.

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

    ready

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions