agc_driver_sampled_cache_budget divides by zero when fixture registrations are contiguous #4141

Closed
opened 2026-10-11 23:57:28 +00:00 by Amoenus · 0 comments
Amoenus commented 2026-10-11 23:57:28 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-11T23:57:28Z.


Resolved upstream

#4159 by MarcZX100 merged2026-10-12, commit34a16b7f, implementing the guard gap and nonzero-charge assertion; this issue is closed as completed. The independent Windows counterexample/validation below remains useful historical evidence. No additional PR is proposed.

Failure

agc_driver_sampled_cache_budget can divide by zero in viewEvictionTests when its two fixture allocations are contiguous. First observed in a full Windows ctest -j4 --timeout 30 run: NUMERICAL, exception 0xc0000094. The dump has rax=0x100000, rcx=0; the faulting executable instruction divides the 1 MiB budget by TextureCacheUsage().sampledBytes.

The current test assumes snapshots remains outside the import made for imported. continuesRun/importRun intentionally joins contiguous registrations with matching permissions. If the two 3 MiB blocks touch, both sampled textures can therefore be storage-image views, charged at zero bytes.

Reproduction and controls

Windows 11 Enterprise 26200, WinLibs GCC 15.2/UCRT/POSIX/SEH r7, Release/testing ON, RTX 5080. Vulkan required, shader cache disabled.

  • External copy of the test: reserve one 6 MiB backing allocation, register its two 3 MiB halves separately with the existing permissions, and use them for snapshots and imported. Keep the original division and checks. Diagnostic output confirms block distance 3,145,728 bytes, charged=0, storageView=1; 5/5 divide-by-zero exits on each of two local integrations, before and after an unrelated resident-MSAA readback change.
  • Same controlled fixture/observer with a 64 KiB unregistered gap between the two blocks: storageView=0 for the snapshot, nonzero charged bytes, 5/5 complete test passes against each library set.
  • Unmodified test: 10/10 isolated passes on the earlier integration; 9/10 on the later one, with the same divide-by-zero in the remaining run. This is a finite observation, not a failure-rate estimate.

These are native-library controls on pinned-main a672688e integrations 406838ac7 and 3d5c594c3, not whole-current-main validation. The test file is byte-for-byte the same Git blob as current main bca7a29d: 0cf28122db6fc3a9549cde83a1011b30d3da1c5f. Original failure, counterexample sources, hashes and logs are retained outside the repository.

Validated local correction (2026-10-12)

Integration commitcfc9b0411 reserves BlockBytes + 65536u using both existing allocator paths, registers only BlockBytes, and requires a nonzero snapshot charge before division. The snapshot/imported registrations therefore cannot touch. No production importer or library source changes.

Windows RTX5080/WinLibs15.2 Release, Vulkan required/cache off: full build/libs/registration/conventions pass; all244 patched/unpatched library files byte-identical before/after this test-only change. The registered test passes 50/50 serial runs (~1.4s each). External controls using the corrected test source: forced contiguous registrations reject5/5 with the new descriptive assertion; removing that assertion reproduces the original arithmetic exception5/5; the same fixture with the unregistered64KiB gap passes5/5 with a nonzero charged snapshot and storageView=0.

Combined with the independently validated merged AMM placement fix, the full870-test integration suite is 865pass/0fail/5 explicit skips, maximum15.57s. These are integration tests, not unchanged-current-main validation; Linux's allocator change has not been run here. No gameplay claim.

Historical one-file preparationd32ceb3c6, basebca7a29d, remains local and is not an additional candidate now that the equivalent correction is merged. The tested integration file is available through the linked fork commit; the fresh088 full suite is867pass/0fail/5skip of872, not unchanged-current-main validation.

Fixture correction now merged

The merged correction reserves an extra unregistered64KiB on both allocator paths and asserts a nonzero snapshot charge before division. The independent forced-contiguous/gap controls above validate the fixture distinction; they do not claim new production-importer behavior.

AI-assisted investigation/report: Codex. No PR or game-startup claim.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5806427362 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4141). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-11T23:57:28Z. --- ## Resolved upstream [#4159 by MarcZX100](https://github.com/boykopovar/AnyPS5/pull/4159) merged2026-10-12, commit`34a16b7f`, implementing the guard gap and nonzero-charge assertion; this issue is closed as completed. The independent Windows counterexample/validation below remains useful historical evidence. No additional PR is proposed. ## Failure `agc_driver_sampled_cache_budget` can divide by zero in `viewEvictionTests` when its two fixture allocations are contiguous. First observed in a full Windows `ctest -j4 --timeout 30` run: `NUMERICAL`, exception `0xc0000094`. The dump has `rax=0x100000`, `rcx=0`; the faulting executable instruction divides the 1 MiB budget by `TextureCacheUsage().sampledBytes`. The [current test](https://github.com/boykopovar/AnyPS5/blob/bca7a29d259299aaa8972c94d12694232bb3bb08/core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp#L444) assumes `snapshots` remains outside the import made for `imported`. [continuesRun/importRun](https://github.com/boykopovar/AnyPS5/blob/bca7a29d259299aaa8972c94d12694232bb3bb08/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L550) intentionally joins contiguous registrations with matching permissions. If the two 3 MiB blocks touch, both sampled textures can therefore be storage-image views, charged at zero bytes. ## Reproduction and controls Windows 11 Enterprise 26200, WinLibs GCC 15.2/UCRT/POSIX/SEH r7, Release/testing ON, RTX 5080. Vulkan required, shader cache disabled. - External copy of the test: reserve one 6 MiB backing allocation, register its two 3 MiB halves separately with the existing permissions, and use them for `snapshots` and `imported`. Keep the original division and checks. Diagnostic output confirms block distance 3,145,728 bytes, `charged=0`, `storageView=1`; **5/5 divide-by-zero exits on each of two local integrations**, before and after an unrelated resident-MSAA readback change. - Same controlled fixture/observer with a **64 KiB unregistered gap** between the two blocks: `storageView=0` for the snapshot, nonzero charged bytes, **5/5 complete test passes against each library set**. - Unmodified test: 10/10 isolated passes on the earlier integration; 9/10 on the later one, with the same divide-by-zero in the remaining run. This is a finite observation, not a failure-rate estimate. These are native-library controls on pinned-main `a672688e` integrations `406838ac7` and `3d5c594c3`, not whole-current-main validation. The test file is byte-for-byte the same Git blob as current main `bca7a29d`: `0cf28122db6fc3a9549cde83a1011b30d3da1c5f`. Original failure, counterexample sources, hashes and logs are retained outside the repository. ## Validated local correction (2026-10-12) [Integration commitcfc9b0411](https://github.com/Amoenus/AnyPS5/commit/cfc9b0411462ec3ff3907d4d0662d0238286c84d) reserves `BlockBytes + 65536u` using both existing allocator paths, registers only `BlockBytes`, and requires a nonzero snapshot charge before division. The snapshot/imported registrations therefore cannot touch. No production importer or library source changes. Windows RTX5080/WinLibs15.2 Release, Vulkan required/cache off: full build/libs/registration/conventions pass; **all244 patched/unpatched library files byte-identical** before/after this test-only change. The registered test passes **50/50** serial runs (~1.4s each). External controls using the corrected test source: forced contiguous registrations reject5/5 with the new descriptive assertion; removing that assertion reproduces the original arithmetic exception5/5; the same fixture with the unregistered64KiB gap passes5/5 with a nonzero charged snapshot and `storageView=0`. Combined with the independently validated merged AMM placement fix, the full870-test integration suite is **865pass/0fail/5 explicit skips**, maximum15.57s. These are integration tests, not unchanged-current-main validation; Linux's allocator change has not been run here. No gameplay claim. Historical one-file preparation`d32ceb3c6`, base`bca7a29d`, remains local and is not an additional candidate now that the equivalent correction is merged. The tested integration file is available through the linked fork commit; the fresh088 full suite is867pass/0fail/5skip of872, not unchanged-current-main validation. ## Fixture correction now merged The merged correction reserves an extra unregistered64KiB on both allocator paths and asserts a nonzero snapshot charge before division. The independent forced-contiguous/gap controls above validate the fixture distinction; they do not claim new production-importer behavior. AI-assisted investigation/report: Codex. No PR or game-startup claim.
Sign in to join this conversation.
No labels
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.

Reference
boykopovar/AnyPS5#4141
No description provided.