Skip to content

test: drive the fallback warning countdown with a manual clock (Fixes #3908) - #5427

Merged
rdoupe merged 1 commit into
masterfrom
test/3908-fallback-warning-clock
Nov 22, 2026
Merged

rdoupe merged 1 commit into
masterfrom
test/3908-fallback-warning-clock

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #3908

test_fallback_warning_dialog raced its own countdowns against wall time. countdown_moves_the_progress showed a 2000 ms countdown, waited 400 ms, then read s.dialog->findChild(...) without checking the QPointer. A runner that stalls for 2 s or more inside that wait lets the countdown finish, the dialog deletes itself, and the read dereferences null. cmocka then leaves the test by longjmp, skipping the destructor of the stack Shown, which is the 180-byte LeakSanitizer report in #3871. The button, Escape, close and modal-pause cases had the same race against 300-400 ms countdowns.

This is the fixture correction decided on the issue (2026-11-21): a test-only change to a test we wrote for the C++-only dialog (#2238), not an accommodation of a Rust port.

Change

  • OBSFallbackWarning takes an optional Clock (monotonic ms). Empty, which is what frontend/utility/FallbackWarning.cpp.hpp passes, it starts its QElapsedTimer as before. tick() computes the same step as clock.restart() did, before the modal check, so time spent behind another modal dialog is still discarded. Countdown length, tick interval, auto-accept and exactly-once ending are unchanged.
  • The test gives each dialog a manual clock. Only advance() moves it, and the test waits on events (QTest::qWaitFor with a 30 s bound that only turns a hang into a failure), so no countdown can expire before the test lets it.
  • Button, Escape and close cases act first, then advance past the countdown, keeping the "a stopped countdown must not end it again" check.
  • Every dereference of the dialog checks it is still alive first, so a regression fails as an assertion, not SIGSEGV.
  • Shown is allocated in cmocka setup and freed in teardown, so a failed assertion leaks nothing.
  • New case countdown_accepts_once_on_real_time: the default clock still counts down and accepts once. It waits for the end instead of timing it.

Every existing assertion is kept.

Evidence

The test built on its own (host Qt 6, -fsanitize=address, QT_QPA_PLATFORM=offscreen, same two sources as its test-graph.json entry).

RED (origin/master 7e17e7383, a scratch QTest::qWait(2500) after settle(400) in countdown_moves_the_progress, not committed):

[ RUN      ] countdown_moves_the_progress
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] countdown_moves_the_progress
==ERROR: LeakSanitizer: detected memory leaks
SUMMARY: AddressSanitizer: 180 byte(s) leaked in 4 allocation(s).
exit=1

GREEN, the same scratch stall after advance(s, 400) in the new test:

[ RUN      ] countdown_moves_the_progress
[       OK ] countdown_moves_the_progress
[  PASSED  ] 1 test(s).
exit=0

Full suite, unmodified: 10 of 10 pass under ASan with no leak report. 100 consecutive runs of the whole suite while 16 busy loops held all 16 cores: 100/100 passed (a shell loop over the binary, stopping at the first non-zero exit).

./lint passes.

🤖 Generated with Claude Code

…3908)

test_fallback_warning_dialog raced its countdowns against wall time: a
runner stalled for 2 s inside countdown_moves_the_progress let the dialog
finish and delete itself, and the next read dereferenced a null QPointer
(the SIGSEGV plus 180-byte leak in #3871).

OBSFallbackWarning takes an optional monotonic Clock; empty, as every
caller passes, it keeps its QElapsedTimer. The test advances a manual
clock and waits on events, checks the dialog is alive before each
dereference, and owns Shown in cmocka setup/teardown. Every existing
assertion stays; a new case covers the default clock by waiting for the
end. Test-only change to our own C++ test, per the decision on #3908.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1795317098,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":93,"stamp":"aae4547e0c056696ca6c52459afa56f7","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317098,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":93,"stamp":"997c1d862365769367c4ca86b979e892","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317098,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":93,"stamp":"24a43744a949101f927ec1796b887ce7","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317098,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":93,"stamp":"02b30f7012013937c8ec08057724c039","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317004,"gate":"general/all/client-lint","host":"linux-x86_64","key":"e398822f5e9231ea0ed5d46fc3fcd63badb7e741a9ccb4e5ad04ced22562b49c","lane":"client-lint","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":10,"stamp":"c3c6139588bca0ad557fd9bc92793ff4","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317098,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":93,"stamp":"3dbb8a0b957e9d5fb065417641e5a676","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317004,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"e398822f5e9231ea0ed5d46fc3fcd63badb7e741a9ccb4e5ad04ced22562b49c","lane":"client-lint","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":10,"stamp":"298c2c10536aec5ef69e9b0c69758c39","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317004,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"e398822f5e9231ea0ed5d46fc3fcd63badb7e741a9ccb4e5ad04ced22562b49c","lane":"client-lint","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":10,"stamp":"576d787bb1466672fefb7e0e8251a0ec","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317004,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"e398822f5e9231ea0ed5d46fc3fcd63badb7e741a9ccb4e5ad04ced22562b49c","lane":"client-lint","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":10,"stamp":"187c9e4de37e7b660689022b9a17e54f","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317004,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"e398822f5e9231ea0ed5d46fc3fcd63badb7e741a9ccb4e5ad04ced22562b49c","lane":"client-lint","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":10,"stamp":"471d0b401867a2581fd57044d8e84b99","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317004,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"e398822f5e9231ea0ed5d46fc3fcd63badb7e741a9ccb4e5ad04ced22562b49c","lane":"client-lint","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":10,"stamp":"f8f0794921073d81668daf2093fe8b13","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317004,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"e398822f5e9231ea0ed5d46fc3fcd63badb7e741a9ccb4e5ad04ced22562b49c","lane":"client-lint","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":10,"stamp":"56b76f05068e0f0edb4c1c6b602c19ca","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317004,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"e398822f5e9231ea0ed5d46fc3fcd63badb7e741a9ccb4e5ad04ced22562b49c","lane":"client-lint","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":10,"stamp":"63a042ae61ab577f5f15f3e3193f1768","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317004,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"e398822f5e9231ea0ed5d46fc3fcd63badb7e741a9ccb4e5ad04ced22562b49c","lane":"client-lint","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":10,"stamp":"dc329bc45a2c2f77fa0893f9769c7202","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317004,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"e398822f5e9231ea0ed5d46fc3fcd63badb7e741a9ccb4e5ad04ced22562b49c","lane":"client-lint","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":10,"stamp":"7035f6cb800f5ce247b8786521ebd251","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317004,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"e398822f5e9231ea0ed5d46fc3fcd63badb7e741a9ccb4e5ad04ced22562b49c","lane":"client-lint","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":10,"stamp":"f482b96106c412fcea0ba17b48750756","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317004,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"e398822f5e9231ea0ed5d46fc3fcd63badb7e741a9ccb4e5ad04ced22562b49c","lane":"client-lint","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":10,"stamp":"124a6065fdb9d1575c29d0fc0841b294","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317004,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"e398822f5e9231ea0ed5d46fc3fcd63badb7e741a9ccb4e5ad04ced22562b49c","lane":"client-lint","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":10,"stamp":"79ab06f4c1a0e5566d75134937990b58","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}
Ci-Attestation: {"at":1795317301,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"e139090ec62d22b66b695b962fddca983d7859f8823bb2f0ad2302ae96b4d348","lane":"client-test-x86_64-unknown-linux-gnu","parents":["7e17e738386d224416e7acd8d5de78b7d9065171"],"secs":202,"stamp":"4b67bd45d092841f24de830133d78784","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"ec9208d1cd391d5f052dc510b7dc252a43bc75d5","coverage":"all-tracked-applicable-files","diff":["frontend/dialogs/OBSFallbackWarning.cpp.hpp","frontend/dialogs/OBSFallbackWarning.hpp","libobs/build/libobs.core+.h.c","libobs/build/libobs.ported-get-video+.h.c","libobs/build/ported-source-sets/get-video.json","libobs/cmake/rust-exports.d/obs-core-get_video.txt","libobs/obs-get-video-fields.c.h","rust/README.md","rust/obs-c-oracle/oracle/get_video.c","rust/obs-core/src/ffi/get_video.rs","rust/obs-core/src/ffi/mod.rs","rust/obs-core/src/get_video.rs","rust/obs-core/src/lib.rs","rust/obs-core/tests/obs_core/get_video.rs","rust/obs-core/tests/obs_core/get_video_parity.rs","rust/obs-core/tests/obs_core/main.rs","test/cmocka/build/rust-static-support.json","test/cmocka/get-video-link-support.c","test/cmocka/test_fallback_warning_dialog.cpp"],"head":"ce6c78a684e25eb7401f393ce5af3278f46f9ff2","tools":{"orchestrator-python":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]","schema-dependencies":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]\n{'jsonschema': '4.26.0', 'json_source_map': '1.0.5'}","uv":"uv 0.13.5 (x86_64-unknown-linux-gnu)","xmllint":"xmllint: using libxml version 21504-GITv2.15.4\n   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ICU ISO8859X Regexps Automata RelaxNG Schemas Schematron Modules Debug Zlib"},"tracked-digest":"aec838430e0d92054fdaaa8f6b51136b25c9dcc90d5d79efbb2c0e35399ee453","tree":"b0e14e850ae6abb89dc4e678c95a42f774559833"}}
@rdoupe
rdoupe requested a review from zackees as a code owner November 22, 2026 03:15
@rdoupe
rdoupe enabled auto-merge November 22, 2026 03:15

@zackees zackees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator review: approved.

  • Matches the #3908 decision. The dialog gets an optional clock, empty by default. Real callers (FallbackWarning.cpp.hpp) pass nothing, and the default path is equivalent to the old code: now() reads the QElapsedTimer started in the constructor, and now() - lastTick is what clock.restart() returned. Countdown length, tick interval, auto-accept, the exactly-once ending and the modal-pause discard (the step is still computed before the modal check) are unchanged. OBSFallbackWarning.hpp is a frontend header, not a public C header.
  • The test:
    • A manual clock, plus waits on events with a 30 s bound that only turns a hang into a failure, so no countdown races wall time.
    • Every dialog read checks the QPointer first.
    • Shown moved into setup and teardown, so a failed assertion leaks nothing.
    • Every existing assertion is kept, and the new countdown_accepts_once_on_real_time covers the default clock.
  • Evidence: the RED scratch stall gives SIGSEGV plus the 180-byte leak on master, and passes on this branch. 10/10 under ASan, and 100/100 under full-core load.

@rdoupe
rdoupe added this pull request to the merge queue Nov 22, 2026
Merged via the queue into master with commit cb31f5a Nov 22, 2026
46 checks passed
@rdoupe
rdoupe deleted the test/3908-fallback-warning-clock branch November 22, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

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

2 participants