GPU frame events: concurrent FLIP waits can consume the same tick #244

Open
opened 2026-11-26 03:39:11 +00:00 by github-bot · 1 comment
Owner

@⁠Bennet0k on GitHub · 2026-11-24 22:59 UTC · original

Source

Two waits can pick the same tick before either has advanced LAST. Both return S_OK even though only one tick was consumed. A Rust harness running the frame wait logic from 2119b0e used a barrier to start two FLIP waits and observed two successful calls with LAST == 1. No GPU or game was needed.

Proposed fix. Use the previous value returned from fetch_max to decide whether the waiter claimed the tick. If another waiter consumed it first, recompute the wait against the original deadline and retry. The standalone regression fails on the original logic and passes with this change. Keep a separate timeout regression to ensure a retry does not extend the caller's timeout.

Found in an AI-assisted audit of 2119b0e.

**@⁠Bennet0k** on GitHub · 2026-11-24 22:59 UTC · [original](https://github.com/fxceless/victory-fork/issues/244) [Source](https://github.com/fxceless/victory-fork/blob/2119b0e44c53aa9648307b0c5c73590290305b1f/crates/victory-gpu/src/frame.rs#L95-L151) Two waits can pick the same tick before either has advanced `LAST`. Both return `S_OK` even though only one tick was consumed. A Rust harness running the frame wait logic from `2119b0e` used a barrier to start two `FLIP` waits and observed two successful calls with `LAST == 1`. No GPU or game was needed. **Proposed fix.** Use the previous value returned from `fetch_max` to decide whether the waiter claimed the tick. If another waiter consumed it first, recompute the wait against the original deadline and retry. The standalone regression fails on the original logic and passes with this change. Keep a separate timeout regression to ensure a retry does not extend the caller's timeout. Found in an AI-assisted audit of `2119b0e`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:39:11 +00:00
Author
Owner

@⁠avt0m4t48 on GitHub · 2026-11-25 14:44 UTC · original

I compared current main 0b0074e, #281 at 105ccf4, and #325 at b8d6426 with the same Linux Rust harness. A test-only barrier immediately before fetch_max makes both waiters reach the claim for tick 1 before either can advance it. The harness records the requested tick, the old value returned by the atomic, and both HRESULTs.

  • With a 460 ms timeout and 300 ms ticks, main returned two successes for tick 1. Both PRs returned one success and one timeout.
  • With a 910 ms timeout, main again returned two successes for tick 1. Both PRs returned success on ticks 1 and 2.

The two candidates agree on these controls. #281 currently merges cleanly and retains the newer frame-log instrumentation. These are synthetic CPU tests. #978 independently addresses the sequential test's assumptions about scheduling delays.

AI-assisted using Codex.

**@⁠avt0m4t48** on GitHub · 2026-11-25 14:44 UTC · [original](https://github.com/fxceless/victory-fork/issues/244#issuecomment-7165743056) I compared current main `0b0074e`, #281 at `105ccf4`, and #325 at `b8d6426` with the same Linux Rust harness. A test-only barrier immediately before `fetch_max` makes both waiters reach the claim for tick 1 before either can advance it. The harness records the requested tick, the old value returned by the atomic, and both HRESULTs. - With a 460 ms timeout and 300 ms ticks, main returned two successes for tick 1. Both PRs returned one success and one timeout. - With a 910 ms timeout, main again returned two successes for tick 1. Both PRs returned success on ticks 1 and 2. The two candidates agree on these controls. #281 currently merges cleanly and retains the newer frame-log instrumentation. These are synthetic CPU tests. #978 independently addresses the sequential test's assumptions about scheduling delays. AI-assisted using Codex.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/fxceless--victory-fork#244
No description provided.