memory: stop logging clamped buffer ranges #2540

Manually merged
github merged 4 commits from gh-pr/2540/head into gh-pr/2540/base 2026-11-26 10:22:32 +00:00
Owner

@⁠Nawid3333 on GitHub · 2026-11-24 07:36 UTC · original
Nawid3333:fix/stop-logging-clamped-ranges → main · +0 −5 · 1 files · 4 commits · merged 2026-11-25 01:13 UTC

ClampRangeSize writes Memory: clamped buffer range addr=... size=... to ... each time it shortens a buffer range that reaches past mapped memory. Games bind the same oversized buffer again and again, so tester logs fill with the same line:

Report Build Lines Share of _kyty.txt Distinct ranges
#2282 (MXGP 26) KytyPS5-2026-11-14-3e226bf 2,262,047 36.5 % of 614 MB 1
#2083 (Cronos: The New Dawn) KytyPS5-2026-11-21-6133172 1,587,914 40.8 % of 385 MB 1
#2351 (The Blood of Dawnwalker) KytyPS5-2026-11-16-1e87171 563,402 46.0 % of 121 MB 3
#2308 (Assassin's Creed Valhalla) KytyPS5-2026-11-16-d45b086 351,198 29.0 % of 120 MB 7

Logs this size are too large to attach, so testers have to cut them down first. The clamp itself stays, and an empty result still stops with attempted to access invalid address. Only the log line goes, like the flip and vblank poll lines in f0708e70f.

Test

Log text only, so no unit test. Fork CI (Windows, Linux, macOS): https://github.com/Nawid3333/KytyPS5/actions/runs/45336201063/attempts/2

No game run of this branch.

Written with Claude Code (AI): Claude Code wrote the change and counted the lines in the tester logs.

🤖 Generated with Claude Code

**@⁠Nawid3333** on GitHub · 2026-11-24 07:36 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2540) `Nawid3333:fix/stop-logging-clamped-ranges` → `main` · +0 −5 · 1 files · 4 commits · merged 2026-11-25 01:13 UTC `ClampRangeSize` writes `Memory: clamped buffer range addr=... size=... to ...` each time it shortens a buffer range that reaches past mapped memory. Games bind the same oversized buffer again and again, so tester logs fill with the same line: | Report | Build | Lines | Share of `_kyty.txt` | Distinct ranges | |---|---|---|---|---| | #2282 (MXGP 26) | `KytyPS5-2026-11-14-3e226bf` | 2,262,047 | 36.5 % of 614 MB | 1 | | #2083 (Cronos: The New Dawn) | `KytyPS5-2026-11-21-6133172` | 1,587,914 | 40.8 % of 385 MB | 1 | | #2351 (The Blood of Dawnwalker) | `KytyPS5-2026-11-16-1e87171` | 563,402 | 46.0 % of 121 MB | 3 | | #2308 (Assassin's Creed Valhalla) | `KytyPS5-2026-11-16-d45b086` | 351,198 | 29.0 % of 120 MB | 7 | Logs this size are too large to attach, so testers have to cut them down first. The clamp itself stays, and an empty result still stops with `attempted to access invalid address`. Only the log line goes, like the flip and vblank poll lines in f0708e70f. ## Test Log text only, so no unit test. Fork CI (Windows, Linux, macOS): https://github.com/Nawid3333/KytyPS5/actions/runs/45336201063/attempts/2 No game run of this branch. Written with Claude Code (AI): Claude Code wrote the change and counted the lines in the tester logs. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep the clamped-range line, but print it only when the clamp differs
from the last one this thread printed. In the four tester logs of the
first version the 0.35-2.26 M copies are 1, 1, 7 and 3 distinct ranges;
the rule leaves 1, 1, 8 and 3 lines. The test clamps two ranges at a hole
five times and expects three lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
While logging is silent nothing is printed, so the last printed clamp
must not change; otherwise enabling the log later would hide a range
this thread never printed. The test now clamps once while silent first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:22:28 +00:00
github manually merged commit 5e0fd3b5da into gh-pr/2540/base 2026-11-26 10:22:32 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-24 07:37 UTC · original · edited 2026-11-25 01:16 UTC

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

ClampRangeSize now suppresses a clamp warning when the same {vaddr, size, clamped_size} tuple was previously logged on the current thread. It logs a warning when that tuple changes. Clamp results and invalid-address failure behavior remain unchanged. A new test checks returned sizes and verifies the warning count across five calls.

Suggested reviewers: nmzik

Change: Other

Merge Risk: Minimal · up to 64ec9

This change reduces repeated clamp warnings in logs and does not alter clamping results or error behavior. A new test covers the logging behavior. I see no remaining merge risk.

Pre-merge checks: Passed 4

Check name Status Explanation
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.
Title check Passed The title "memory: stop logging clamped buffer ranges" matches the main change: ClampRangeSize no longer logs every shortened range, and the log line is now printed only when the range differs from th…
Description check Passed The description explains the ClampRangeSize log line that is removed, why testers' logs grow too large, and the affected reports. It also states that the clamp remains, that the change touches only lo…
Full details: Title check

Explanation

The title "memory: stop logging clamped buffer ranges" matches the main change: ClampRangeSize no longer logs every shortened range, and the log line is now printed only when the range differs from the last logged one. The title is specific and concise, and it omits only the test addition, which is expected.

Full details: Description check

Explanation

The description explains the ClampRangeSize log line that is removed, why testers' logs grow too large, and the affected reports. It also states that the clamp remains, that the change touches only log text, and what CI ran. It is directly related to the changeset.

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4d37a35a05 and 64ec9f9fe1.

Files selected for processing: 2

  • src/kernel/memory.cpp
  • tests/VirtualMemoryAllocationTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-24 07:37 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2540#issuecomment-7125197435) · edited 2026-11-25 01:16 UTC <!-- coderabbit-ai-generated:v1 --> <!-- 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/2540?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-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_status_start --> No actionable comments were generated in the recent review. <!-- recent_review_status_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> <br> ClampRangeSize now suppresses a clamp warning when the same `{vaddr, size, clamped_size}` tuple was previously logged on the current thread. It logs a warning when that tuple changes. Clamp results and invalid-address failure behavior remain unchanged. A new test checks returned sizes and verifies the warning count across five calls. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"64ec9f9fe1df6891008b2b5cad2d141dbd56b45d" --> <!-- change_assessment_priority:{"version":1,"urgency":"p3","manual":false} --> **Change:** Other <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>64ec9</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `64ec9` --> <!-- final_review_risk_coverage:{"sourceCommitId":"64ec9f9fe1df6891008b2b5cad2d141dbd56b45d","coveredCommitId":"64ec9f9fe1df6891008b2b5cad2d141dbd56b45d","kind":"reviewed"} --> This change reduces repeated clamp warnings in logs and does not alter clamping results or error behavior. A new test covers the logging behavior. I see no remaining merge risk. <!-- 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</strong></summary> <dl> <dd> <br> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 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. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title "memory: stop logging clamped buffer ranges" matches the main change: ClampRangeSize no longer logs every shortened range, and the log line is now printed only when the range differs from th… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description explains the ClampRangeSize log line that is removed, why testers' logs grow too large, and the affected reports. It also states that the clamp remains, that the change touches only lo… | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> <br> **Explanation** The title "memory: stop logging clamped buffer ranges" matches the main change: ClampRangeSize no longer logs every shortened range, and the log line is now printed only when the range differs from the last logged one. The title is specific and concise, and it omits only the test addition, which is expected. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> <br> **Explanation** The description explains the ClampRangeSize log line that is removed, why testers' logs grow too large, and the affected reports. It also states that the clamp remains, that the change touches only log text, and what CI ran. It is directly related to the changeset. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=2540)! 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> <br> - [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> <!-- tips_end --> <!-- recent_review_start --> <h6> <details> <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary> <dl> <dd> <br> <!-- review_info_content --> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/4e90654506c8078649e2c1d22c763164406497da/.coderabbit.yaml>) - **Commit**: [4e90654](<https://github.com/KytyPS5/KytyPS5/commit/4e90654506c8078649e2c1d22c763164406497da>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `8ba871d0-6a29-4663-8936-af8e53403bfd` </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between 4d37a35a0514f891ed61d0b092af9c88b5729a84 and 64ec9f9fe1df6891008b2b5cad2d141dbd56b45d. </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 2</strong></summary> <dl> <dd> <br> * `src/kernel/memory.cpp` * `tests/VirtualMemoryAllocationTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. </dd> </dl> </details> </h6> <!-- recent_review_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-24 09:03 UTC · original · reviewed

Actionable comments posted: 1

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between eb08c9f0c5 and 4d37a35a05.

Files selected for processing: 2

  • src/kernel/memory.cpp
  • tests/VirtualMemoryAllocationTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-24 09:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2540#pullrequestreview-6036350068) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/4e90654506c8078649e2c1d22c763164406497da/.coderabbit.yaml>) - **Commit**: [4e90654](<https://github.com/KytyPS5/KytyPS5/commit/4e90654506c8078649e2c1d22c763164406497da>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `07684f3f-a4bc-42c0-92e3-843ca1cba72b` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between eb08c9f0c545c8f695a2042bc09665b15c4f0c76 and 4d37a35a0514f891ed61d0b092af9c88b5729a84. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 2</summary> <dl> <dd> <br> * `src/kernel/memory.cpp` * `tests/VirtualMemoryAllocationTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=e4c1d341-63a2-423a-91d8-e3a5dacb1842 attempt=3994e807-e601-4aae-803a-4790e59bb8d4 batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-24 09:03 UTC · original · edited 2026-11-24 09:12 UTC
On src/kernel/memory.cpp line 855 (outdated):

@@ -849,7 +850,9 @@ uint64_t ClampRangeSize(uint64_t vaddr, uint64_t size, bool span_holes) {
 		     "\n",
 		     vaddr, size);
 	}
-	if (clamped_size != size) {
+	static thread_local std::array<uint64_t, 3> logged_clamp {};
+	const std::array<uint64_t, 3>               clamp {vaddr, size, clamped_size};
+	if (clamped_size != size && std::exchange(logged_clamp, clamp) != clamp) {

Minor · Functional Correctness · Quick win

Do not record clamps that silent logging discards.

If a thread clamps A while logging is silent, std::exchange still records A. If logging is then enabled, repeating A produces no warning, although this thread never printed A.

Check Log::IsSilent() before updating logged_clamp. This preserves suppression for visible A,A and logging for visible A,B,A.

The commit objective specifies the last clamp this thread printed.

✅ Addressed in commit 64ec9f9

**@⁠coderabbitai[bot]** on GitHub · 2026-11-24 09:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2540#discussion_r4677669125) · edited 2026-11-24 09:12 UTC On `src/kernel/memory.cpp` line 855 (outdated): ```diff @@ -849,7 +850,9 @@ uint64_t ClampRangeSize(uint64_t vaddr, uint64_t size, bool span_holes) { "\n", vaddr, size); } - if (clamped_size != size) { + static thread_local std::array<uint64_t, 3> logged_clamp {}; + const std::array<uint64_t, 3> clamp {vaddr, size, clamped_size}; + if (clamped_size != size && std::exchange(logged_clamp, clamp) != clamp) { ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Do not record clamps that silent logging discards.** If a thread clamps A while logging is silent, `std::exchange` still records A. If logging is then enabled, repeating A produces no warning, although this thread never printed A. Check `Log::IsSilent()` before updating `logged_clamp`. This preserves suppression for visible A,A and logging for visible A,B,A. The commit objective specifies the last clamp this thread printed. <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:ab3e5ac9acd21c1a6292f397 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 64ec9f9
This discussion has been locked. Commenting is limited to contributors.
No description provided.