Skip to content

fix(vulkan): bound configured frame waits to ring capacity - #1113

Merged
NotRexed merged 5 commits into
NotRexed:mainfrom
monsterlag:fix/frame-wait-ring-bounds
Nov 10, 2026
Merged

NotRexed merged 5 commits into
NotRexed:mainfrom
monsterlag:fix/frame-wait-ring-bounds

Conversation

@monsterlag

@monsterlag monsterlag commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

RX_VK_WAIT_GPU used an unchecked parsed count to index an eight-entry ring. A positive setting above eight could read and write outside that array. Bound the read-once setting to the actual ring capacity before converting it to int or indexing. strtol safely handles values outside the integer range; whitespace, signs and numeric prefixes remain accepted.

Unset, zero, negative and nonnumeric settings remain disabled. Counts one through eight keep their timeline-value wait order. An oversized setting prints one diagnostic showing the effective limit, so a player requesting 12 frames can see that the ring holds eight. This fixes an opt-in configuration bounds bug; it does not explain issue #1106's setting of zero or claim a default-performance improvement.

The authored regression extracts the actual initialization and complete replay wait block, adding a pre-index observer so the original-source negative rejects an out-of-range count without an invalid memory access. All 18 cases cover valid counts, disabled inputs, numeric prefixes, oversized/overflow inputs, read-once behavior, wait ordering and one-time diagnostics.

Validation on 01f4317, merged with upstream 7dbdcdc:

  • All 18 cases pass with Windows LLVM-MinGW and Linux GCC under -Wall -Wextra -Werror. The strict focused runner passes with zero failures or skips.
  • Before adding the diagnostic, its three oversized-input cases fail while 15 controls pass with the same fixture.
  • Against original main 8b2e1d3, the bounds regression previously rejected representable counts 9 and 2147483647 before indexing; 14 controls passed. Original atoi overflow inputs and invalid ring accesses were not executed.
  • The PR diff passes whitespace checks. All eight hosted validation checks pass for this head; release publishing is skipped for the PR.

No Vulkan device, game, shader compiler, actual GPU wait or physical presentation measurement is used by this fixture. Prior Windows MSVC-target Clang validation passed all 18 original bounds cases; that target has not been rerun for the added diagnostic.

monsterlag and others added 3 commits November 9, 2026 07:06
Parse the opt-in frame count with strtol and clamp it before casting or indexing the fixed ring. Preserve disabled settings, numeric prefixes, read-once behavior and valid wait ordering.

Assisted-by: OpenAI Codex

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Keep the frame-wait fixture strict while matching the production CRT definition needed by MSVC-target Clang. Preserve all parsing, bounds and ordering assertions.

Assisted-by: OpenAI Codex

Co-Authored-By: OpenAI Codex <noreply@openai.com>
@NotRexed

Copy link
Copy Markdown
Owner

This landed in the v2.0.12 branch (merged there for testing; it reaches main with that release), so closing. Thanks!

@NotRexed NotRexed closed this Nov 10, 2026
@NotRexed

Copy link
Copy Markdown
Owner

Reopened: closing this was a mistake on my side. It was tested in the v2.0.12 branch, and it will be merged into main here, so it shows as merged. Sorry for the noise.

@NotRexed NotRexed reopened this Nov 10, 2026
@NotRexed
NotRexed merged commit 0f686b6 into NotRexed:main Nov 10, 2026
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.

2 participants