Skip to content

bug: frontend test: fallback countdown races dialog deletion, causing null dereference and fixture leaks #3908

Closed

Description

@zackees

Location

test/cmocka/test_fallback_warning_dialog.cpp:129-141 (countdown_moves_the_progress):

show(s, true, 2000);
settle(400);
auto *progress = s.dialog->findChild<QProgressBar *>("progress");

show pumps Qt events for 20 ms (54-60); settle pumps events, sends deferred deletes and processes events again (64-68). The window has WA_DeleteOnClose (frontend/dialogs/OBSFallbackWarning.cpp.hpp:10), uses a real QElapsedTimer (55-59,87), and finishes/closes when elapsed >= countdown (101-105). QPointer becomes null on deletion.

Class / reachability

Intermittent test null-pointer dereference, followed by test-fixture leaks. Trusted local test execution only. No remote-input or credential-leak finding. This report concerns the isolated Qt dialog test, not the security properties of fallback callers.

Evidence and frequency

PR #3871 attempt 1, job 128409082134 failed: test_fallback_warning_dialog exit=1 (8.3s). The PR ports hotkey getters and changes no frontend dialog code. Its sanitize-asan artifact contains tests/test_fallback_warning_dialog.log and .ubsan.25488.

The test log reports 8/9 cases passing, with only countdown_moves_the_progress failing at line 135 (null OBSFallbackWarning / QObject, then SIGSEGV). The leak stack explicitly runs from settle line 66 / caller line 133 through QTest::qWait, QTimer, OBSFallbackWarning::tick:104, ended, and the callback's ends.push_back:58. Thus the countdown actually completed during the wait, before line 135.

LeakSanitizer reports 180 bytes / 4 allocations: QObject private state from Shown:46 (120), QPointer weak-reference state from show:56 (16), vector allocation from callback line 58 (4), connection state from line 57 (40). Likely secondary to cmocka signal recovery bypassing stack C++ destructors after the fault, rather than a leaked live dialog.

Bounded convenience sample (not an exhaustive incidence estimate): 1 failure / 17 actual test executions checked, 16 passes. Earliest observed failure in this sample: 2026-11-07 13:02 UTC. The test file has been unchanged since #2238 (2026-10-25, 4d73452); this does not establish when failures first began.

Cohort Actual test executions Pass Fail
Recent PRs Nov 7, including reported failure and previous hotkey run 10 9 1
Older PRs Nov 6 3 3 0
Master scheduled sanitizers Nov 3–6 4 4 0

Three sampled successful merge-group runs (42376234390,42371446973,42370675616) have no asan execution; do not count their green workflows as passes. ci.yml --event push returned no runs; current master push workflow push.yaml run 42371994305 only has asan cache-state/refresh jobs and a skipped Sanitize call, also not a test pass.

Previous same hotkey branch: 42368049799 / 128391834166, test exit=0 (6.2s). Representative other PR pass: 42373580556 / 128410223942. Master scheduled passes: 42235134335 / 127950774150, 42049821983 / 127322784486, 41851659014 / 126649434446, 41655492536 / 125984690630.

PR #3871 attempt 2 job 128424520098 remains in progress at this investigation's check; no rerun requested here. One older failed asan job (128221813245) contains no result for this test and is excluded.

Cause and proposed fix / failing-test sketch

The test assumes that pumping events for nominally 400 ms always returns before a real 2000 ms countdown expires. Scheduling/sanitizer overhead can exceed that window. The dialog correctly emits CountdownDone, closes, and deletes itself while Qt events are being pumped. Missing QApplication pumping is not the cause: pumping is visible both in source and in the artifact stack. This is the wall-clock/load class described by #838, though that issue covers audio tests, not this dialog.

Maintainer decision required: the direct correction is in the existing C++ test, which workers must not edit (same policy boundary as #3789/#3808/#3810). No small non-test frontend correctness fix is justified by these logs; changing automatic closure to satisfy the test would change intended behavior.

Prefer a controlled clock/tick observation for progress assertions so reaching nonzero progress cannot race expiration; check lifetime before dereferencing, with cleanup owned outside cmocka's signal/longjmp path. A null assertion alone improves diagnostics but does not fix timing. Increasing the countdown or applying the timing resource lock is only a mitigation. RED sketch: deliberately deschedule/delay the progress test across the countdown deadline; GREEN must inspect intermediate progress without relying on beating wall time. New tests alone cannot remove the existing failing assumption. No source/test edits or claim made during triage.

Searches for test_fallback_warning_dialog, countdown_moves_the_progress, fallback warning and fallback+sanitizer found no dedicated existing report. #1390 mentions the test in the broad native-test migration work; #838 is related background, not a duplicate.

Activity

  1. added
    bug
    on Nov 7, 2026
  2. zackees commented on Nov 11, 2026

    @zackees
    MemberAuthor

    Coordinator investigation confirms the remaining failure is in the existing C++ fixture: settle(400) may deliver deferred deletion after the 2000 ms countdown under load, and the fixture dereferences its QPointer before checking lifetime. The product intentionally auto-closes and must not be changed to rescue this assertion. Maintainer authorization needed: may a narrowly scoped fixture correction use deterministic countdown/event synchronization and safe lifetime observation, preserving automatic completion, exactly-once end and every existing functional assertion? Recommendation: permit only that test correction with focused RED→GREEN evidence; no timing-threshold relaxation or product behavior change. No existing test has been edited by this coordinator work. Reply beginning Decided: or Decision: can define the exception and clear human-review-needed.

  3. added
    human-review-needed
    on Nov 11, 2026
  4. moved this from Triage to Needs decision in obs-rust Multiviewon Nov 11, 2026
  5. zackees commented on Nov 21, 2026

    @zackees
    MemberAuthor

    Decided: yes, the fixture correction is allowed. Scope: test/cmocka/test_fallback_warning_dialog.cpp, plus a behavior-neutral time-source seam in OBSFallbackWarning. The countdown must come from a controlled clock, not from beating wall time. Lifetime is checked before every dereference, and cleanup runs in cmocka teardown. Every existing assertion stays. The countdown still auto-accepts, ends exactly once and deletes itself. No timing threshold is relaxed.

    Why this edit is allowed. The "never edit an existing C test" rule (testing-policy.md, Tier 2) protects tests that check compatibility of a Rust port. This test is one we wrote for the C++-only dialog (#2238), and nothing here accommodates a port. The test has its own race, so fixing it follows the #3810 precedent: a test-only change in its own commit that cites this decision.

    Cause (origin/master a98b199).

    • frontend/dialogs/OBSFallbackWarning.cpp.hpp:55-59,87,101-105: the countdown adds real QElapsedTimer time on each 50 ms tick, then finishes and calls close(). WA_DeleteOnClose (line 10) deletes the dialog.
    • test/cmocka/test_fallback_warning_dialog.cpp:132-135: show(s, true, 2000); settle(400); and then s.dialog->findChild(...) with no null check. When the runner stalls for 2 s or more inside settle, the countdown completes during QTest::qWait. The deferred delete clears the QPointer, and line 135 dereferences null. The stack in the obs-hotkey: Port read-only object field getters (#3868) #3871 artifact shows exactly this: tick:104 → ended → ends.push_back.
    • The 180-byte LeakSanitizer report comes after the crash. cmocka recovers from the signal with longjmp, which skips the destructor of the stack Shown s (its QObject context, the QPointer and the vector).
    • The same race exists in other cases in this file. In each, a step must land before a short real countdown expires:
      • accept_click_ends_once, cancel_click_ends_once, escape_closes and window_close_closes use 300 ms countdowns. If the countdown wins, click() at line 81, keyClick at line 178 and s.dialog->close() at line 216 dereference null, or the recorded end is CountdownDone.
      • countdown_pauses_while_another_dialog_is_modal uses a 400 ms countdown with settle(100) before the modal opens.

    Still on master? Yes, latent. The test and the dialog are unchanged since #2238. No PR references this issue, and known-flaky.txt has no entry for it. The failure is rare: the master asan job passed this test on all 15 scheduled runs from 2026-11-06 to 2026-11-21 (exit=0 (6.2s) each time). No failed PR or merge-queue run from 2026-11-14 to 2026-11-21 shows it. The code path that crashes is still there.

    Fix plan.

    1. Seam: OBSFallbackWarning reads elapsed time through an injectable monotonic time source. By default it uses QElapsedTimer, so live callers such as frontend/utility/FallbackWarning.cpp.hpp:75 behave exactly as before. The seam is test-only and has no new user-facing behavior. OBSFallbackWarning.hpp is a frontend-internal header, not a public C header.
    2. The test uses a manual clock. countdown_moves_the_progress advances it by 400 ms and waits on an event condition: QTest::qWaitFor until progress->value() changes, with a large bound that only turns a hang into a failure. Then it asserts the existing checks: > 0, < 2000, maximum() == 2000, value() == elapsedShown() and ends.empty(). The countdown cannot expire until the test advances time past 2000.
    3. The button, Escape and close cases act before advancing time. Then they advance past the countdown to check that a stopped countdown does not end the dialog again, which preserves the "past the countdown" intent of line 158. countdown_accepts_once advances past its countdown and waits for ended. The pause case advances time while the modal is open and asserts the existing <= before + 100 check and ends.empty(). Then it closes the modal, advances past the countdown and asserts check_one_end(CountdownDone).
    4. Add assert_non_null(s.dialog.data()) before every dereference, so a regression fails as an assertion instead of a SIGSEGV.
    5. Allocate Shown in a cmocka setup and free it in teardown (cmocka_unit_test_setup_teardown), so a failed assertion leaks nothing.

    Acceptance.

    • RED: in a scratch commit on master, add a 2.5 s stall inside countdown_moves_the_progress between show and the progress read. The old test crashes at line 135. With the same stall, the new test passes. Record both outputs in the PR.
    • All 9 cases keep every existing assertion, and the countdown, accept, cancel, Escape and close paths still report exactly one end of the right kind.
    • rust/tools/linux-validate/run.py --repeat 100 --tests test_fallback_warning_dialog runs 100 times clean, and the asan job passes with no LeakSanitizer report.
    • No change to the countdown length, the tick interval, auto-accept or exactly-once behavior for real callers.
  6. added
    ready
    P2
    size:M
    and removed
    human-review-needed
    on Nov 21, 2026
  7. moved this from Needs decision to Ready in obs-rust Multiviewon Nov 22, 2026
  8. rdoupe commented on Nov 22, 2026

    @rdoupe
    Collaborator

    Claiming: the fallback warning dialog test fix, under the 2026-11-21 decision above. Branch: test/3908-fallback-warning-clock.

    1. RED: a scratch stall of 2.5 s inside countdown_moves_the_progress crashes the current test at the progress read (recorded, not committed).
    2. GREEN: an injectable monotonic time source in OBSFallbackWarning (defaults to QElapsedTimer), a manual clock in the test, lifetime asserted before every dereference, Shown owned by cmocka setup/teardown. Every existing assertion stays; the same stall passes.
    3. 100 repeats of test_fallback_warning_dialog, and the asan run clean.
  9. added a commit that references this issue on Nov 23, 2026
    cb31f5a
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