Skip to content

RT-654: retry spurious wakes in the Windows CRT timeout test - #8184

Open
philip-roy-jones wants to merge 2 commits into
ItsNotRexed:mainfrom
philip-roy-jones:test/crt-wait-deadline
Open

philip-roy-jones wants to merge 2 commits into
ItsNotRexed:mainfrom
philip-roy-jones:test/crt-wait-deadline

Conversation

@philip-roy-jones

Copy link
Copy Markdown

Claimed as RT-654. Coordination claim ? Original Windows report

What and why

The CRT regression test expected an unnotified 200 ms condition-variable wait to return timeout on its first call. A condition variable can wake spuriously. On native Windows I saw the original test fail its status assertion even when its other timing and mutex checks passed. Head and parent measurements

The test now calculates one steady_clock deadline after taking the mutex. It retries no_timeout against that deadline, samples the clock immediately after the loop, and checks the final status, deadline, two-second upper bound and mutex ownership. A limit of 1,000 calls catches a wait that continually returns immediately. That limit is a test heuristic.

Tested

I built crt_timed_wait_test with native x64 MSVC 19.51.36248 (/MD, Ninja RelWithDebInfo) on Windows 11 build 26200.9974. The direct run and three serial CTest runs each passed all 13 checks. The registered runs measured 200.374, 200.947 and 201.981 ms.

Synthetic control Observed result
Notification leaves the condition unchanged no_timeout at 169.858 ms, then timeout at 201.532 ms on the same deadline. Passed.
Wait shortened to 160 ms, advertised deadline kept at 200 ms 170.038 and 169.907 ms. Both runs failed the deadline assertion.
Persistent immediate wakes, immediate timeout, dropped notification, excessively late timeout Each control failed its intended check or checks.
cmake --build <build> --config RelWithDebInfo --target crt_timed_wait_test --parallel 2
ctest --test-dir <build> -C RelWithDebInfo -R '^crt_timed_wait$' --no-tests=error -j 1 -V

This is a CPU-only change to runtime/test/crt_timed_wait_test.cpp. The original 199 ms observation has no confirmed cause.

Checklist

  • Only source for the synthetic CRT test is included. The repository's game-data check and git diff --check passed.
  • AI-assisted with Codex.

Retry the unnotified wait against one steady-clock deadline and require a timeout status. Bound the attempts to catch repeated immediate returns alongside the elapsed-time and mutex checks.

AI-assisted (Codex).
Sample the clock as the wait loop exits. Require that instant to reach the original deadline, in addition to the timeout status, and use the same sample for the duration diagnostic and upper bound.

AI-assisted (Codex).

@devnull34 devnull34 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified via Tier 2 Free Cloud (OpenRouter nemotron-3-ultra-550b:free): In crt_timed_wait_test.cpp, retrying cv.wait_until() while status is no_timeout and asserting finished >= deadline reliably handles spurious wakes without failing tests prematurely on busy CI runners.

@casper64114

Copy link
Copy Markdown

Tested 0b984d535342f8b5ee6dd48465bdbc7c27ee9b7c with native MSVC 19.44.35230.0 on Windows 11 build 10.0.26300, Windows SDK 10.0.26100.0. crt_timed_wait_test built successfully; the direct run passed all 13 checks, and three serial CTest runs passed (0.45–0.47 s). The declared base dde82f27 also passed three runs (0.45–0.52 s), so I did not reproduce the intermittent original failure. CPU-only; no game files or GPU. AI-assisted (Codex).

@optinium51-bot

Copy link
Copy Markdown

Tested 0b984d535 merged onto main 867d922f on Windows 11 26200 (Ryzen 9 5950X, RTX 3060 machine), MSVC 14.52 (VS 2026), RelWithDebInfo: pass, and it removes the RT-654 flake here.

crt_timed_wait_test.exe run 240 times, 8 at a time: main fails 18/240 (an unnotified wait_for times out); with this PR 0/240. For comparison, #7686 (1 ms of deadline slop in crt_timed_wait.cpp) still fails 37/240 on the same machine.

No game files. AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants