shader: bound loop-proof analysis for Wolverine #1535

Open
github-bot wants to merge 1 commit from github-bot/gh-1535 into main AGit
Owner

@⁠Qouo on GitHub · 2026-10-15 18:54 UTC · original
Qouo:fix/1513-loop-proof-limits → main · +80 −6 · 2 files · 1 commits · open

Summary

Marvel's Wolverine (PPSA03671) is reported to crash before its first frame with a Windows stack overflow attributed to LoopBoundProof in ResourceTracking.cpp (#1513).

This draft bounds that proof's recursion, work and decision-diagram growth. Exhaustion leaves a loop bound unproven instead of continuing recursive analysis. This is a defensive mitigation for the reported analysis path; it does not establish that Wolverine boots or that its shader can be compiled successfully.

Related to #1513. Please keep this draft pending human review, game reproduction and Linux validation.

Changes

  • Share a depth limit of 128, a work budget of 65,536 proof calls, and a decision-diagram node limit of 16,384 across expression evaluation, selection, comparisons and range membership.
  • Reject the entire proof when its budget is exhausted, including both branch polarities and range-selection proofs. Placeholder results cannot establish a bound.
  • Extend the bounded image-loop regression with shallow/deep Boolean expressions and small/exponential decision diagrams.

Testing

  • Windows: built the launcher and complete kyty_tests target with clang-cl 19.1.5, MSVC 14.44 libraries, Windows SDK 10.0.26100, CMake 3.31.6 and Ninja 1.12.1.
  • Native resource_tracking passes, including the new regression cases.
  • The updated resource-tracking suite fails against the original implementation with oversized decision diagram was accepted as a loop proof, and passes with this change (portable Clang/libc++ test harness).
  • Full native CTest run: 54/55 tests passed. kernel_file_system fails at Net unknown socket options return protocol-option errors; it also fails outside the sandbox. No socket implementation was changed by this contribution.
  • Full native testing used a separate local validation branch with two test-only Windows build fixes: matching aligned allocation/free functions in VdecswTests.cpp, and renaming the small local in the GPU tests. Those fixes are not included here. The macro collision is already covered by #1504.
  • Changed source lines pass clang-format 22.1.3, and git diff --check passes. Whole-file formatting was not included because it rewrites substantial untouched upstream code.
  • Not performed: Wolverine game testing, launcher GUI interaction, or a Linux build. Rejecting an expensive proof can still leave the game's shader unsupported.

AI usage

This contribution is entirely AI work performed by OpenAI Codex. Its investigation, implementation, new regression cases, build/test execution, commits, and this PR description were generated or executed by the AI agent. No human code review or in-game verification is claimed. The upstream game report in #1513 is external evidence, not a game test performed for this contribution.

**@⁠Qouo** on GitHub · 2026-10-15 18:54 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1535) `Qouo:fix/1513-loop-proof-limits` → `main` · +80 −6 · 2 files · 1 commits · open ## Summary Marvel's Wolverine (PPSA03671) is reported to crash before its first frame with a Windows stack overflow attributed to `LoopBoundProof` in `ResourceTracking.cpp` (#1513). This draft bounds that proof's recursion, work and decision-diagram growth. Exhaustion leaves a loop bound unproven instead of continuing recursive analysis. This is a defensive mitigation for the reported analysis path; it does not establish that Wolverine boots or that its shader can be compiled successfully. Related to #1513. Please keep this draft pending human review, game reproduction and Linux validation. ## Changes - Share a depth limit of 128, a work budget of 65,536 proof calls, and a decision-diagram node limit of 16,384 across expression evaluation, selection, comparisons and range membership. - Reject the entire proof when its budget is exhausted, including both branch polarities and range-selection proofs. Placeholder results cannot establish a bound. - Extend the bounded image-loop regression with shallow/deep Boolean expressions and small/exponential decision diagrams. ## Testing - Windows: built the launcher and complete `kyty_tests` target with clang-cl 19.1.5, MSVC 14.44 libraries, Windows SDK 10.0.26100, CMake 3.31.6 and Ninja 1.12.1. - Native `resource_tracking` passes, including the new regression cases. - The updated resource-tracking suite fails against the original implementation with `oversized decision diagram was accepted as a loop proof`, and passes with this change (portable Clang/libc++ test harness). - Full native CTest run: 54/55 tests passed. `kernel_file_system` fails at `Net unknown socket options return protocol-option errors`; it also fails outside the sandbox. No socket implementation was changed by this contribution. - Full native testing used a separate local validation branch with two test-only Windows build fixes: matching aligned allocation/free functions in `VdecswTests.cpp`, and renaming the `small` local in the GPU tests. Those fixes are not included here. The macro collision is already covered by #1504. - Changed source lines pass clang-format 22.1.3, and `git diff --check` passes. Whole-file formatting was not included because it rewrites substantial untouched upstream code. - Not performed: Wolverine game testing, launcher GUI interaction, or a Linux build. Rejecting an expensive proof can still leave the game's shader unsupported. ## AI usage **This contribution is entirely AI work performed by OpenAI Codex.** Its investigation, implementation, new regression cases, build/test execution, commits, and this PR description were generated or executed by the AI agent. No human code review or in-game verification is claimed. The upstream game report in #1513 is external evidence, not a game test performed for this contribution.
Mitigate the unbounded LoopBoundProof analysis reported in #1513. Reject an exhausted proof conservatively across branch polarities and range selection, and cover deep expressions and exponential decision diagrams.

Validation: resource_tracking_tests passes; the original implementation fails the oversized-diagram regression. Game boot behavior and full clang-cl/Linux builds remain unverified. Changed lines pass clang-format 22.1.3; skip whole-file formatting to avoid unrelated upstream reformatting.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:56 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-19 19:11 UTC · original

Review in Change Stack →

📝 Walkthrough

Loop-bound proofs now stop when recursion depth, evaluation steps, or node count exceed configured limits. Exhausted proofs cannot establish exclusions or selected ranges. Tests cover accepted proof depths and widths, plus failures for larger widths and depths across three loop variants.

Suggested reviewers: nmzik

Priority: ⬆️ High

Change: Bug fix

Merge Risk: 🔵 Low · up to 4609f

The proof limits have no established production defect, but the regression tests could pass for the wrong reason. Strengthen the assertions to protect the intended behavior.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description clearly explains the bounded LoopBoundProof analysis, regression tests, validation results, and known limitations.
Title check Passed The title is concise and accurately identifies the shader loop-proof analysis change for Wolverine.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-19 19:11 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1535#issuecomment-6275152238) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1535?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> Loop-bound proofs now stop when recursion depth, evaluation steps, or node count exceed configured limits. Exhausted proofs cannot establish exclusions or selected ranges. Tests cover accepted proof depths and widths, plus failures for larger widths and depths across three loop variants. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬆️ High <!-- change_assessment_commit:"4609f3d00465fe6a4622d2181aa5ca135e433183" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🔵 Low</strong> · up to <code>4609f</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `4609f` --> <!-- final_review_risk_coverage:{"sourceCommitId":"4609f3d00465fe6a4622d2181aa5ca135e433183","coveredCommitId":"4609f3d00465fe6a4622d2181aa5ca135e433183","kind":"reviewed"} --> The proof limits have no established production defect, but the regression tests could pass for the wrong reason. Strengthen the assertions to protect the intended behavior. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 2 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------- | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description clearly explains the bounded LoopBoundProof analysis, regression tests, validation results, and known limitations. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title is concise and accurately identifies the shader loop-proof analysis change for Wolverine. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1535)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-19 19:11 UTC · original · reviewed

🧹 Nitpick comments: 1
tests/ResourceTrackingTests.cpp: 1

1405-1414: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Make the regression assertions identify proof exhaustion.

The width-16 and depth-512 cases only match the generic "not a valid runtime value" text. An unrelated runtime-value validation failure can therefore satisfy both assertions before LoopBoundProof exhausts its budget. This leaves the intended proof-limit regression untested.

Use a proof-exhaustion-specific observable, or make the test inspect the propagated proof result, so these cases fail when the proof is rejected for the wrong reason.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3fad5769-7d36-4663-b883-dd84a6aace29
📥 Commits

Reviewing files that changed from the base of the PR and between 9e41d8320a and 4609f3d004.

📒 Files selected for processing: 2
  • src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
  • tests/ResourceTrackingTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-19 19:11 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1535#pullrequestreview-5576434091) · **reviewed** <details> <summary>🧹 Nitpick comments: 1</summary><blockquote> <details> <summary>tests/ResourceTrackingTests.cpp: 1</summary><blockquote> `1405-1414`: **🎯 Functional Correctness** | **🔵 Trivial** | **⚡ Quick win** **Make the regression assertions identify proof exhaustion.** The width-16 and depth-512 cases only match the generic `"not a valid runtime value"` text. An unrelated runtime-value validation failure can therefore satisfy both assertions before `LoopBoundProof` exhausts its budget. This leaves the intended proof-limit regression untested. Use a proof-exhaustion-specific observable, or make the test inspect the propagated proof result, so these cases fail when the proof is rejected for the wrong reason. <!-- cr-comment:v1:ddd13598f3b5453ccf524bb6 --> </blockquote></details> </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `3fad5769-7d36-4663-b883-dd84a6aace29` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 9e41d8320a2774b303fbad344c2347e8d0292e83 and 4609f3d00465fe6a4622d2181aa5ca135e433183. </details> <details> <summary>📒 Files selected for processing: 2</summary> * `src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp` * `tests/ResourceTrackingTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=706fb51b-29d2-4ed8-b64d-42875cbe42ca attempt=09cdf02b-1887-4b65-b7c5-c2b5b159d667 batch=1/1 -->
This pull request has changes conflicting with the target branch.
  • src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
  • tests/ResourceTrackingTests.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1535/head:github-bot/gh-1535'
git switch 'github-bot/gh-1535'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1535'
git switch 'github-bot/gh-1535'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1535'
git switch 'github-bot/gh-1535'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1535'
git switch 'main'
git merge --squash 'github-bot/gh-1535'
git switch 'main'
git merge --ff-only 'github-bot/gh-1535'
git switch 'main'
git merge 'github-bot/gh-1535'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.