test(agc): give the draw snapshot table set test texels for its whole surface #9236

Merged
milescoviello merged 1 commit from upstream-pr/9236 into main 2026-10-24 18:03:14 +00:00
milescoviello commented 2026-10-21 16:07:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T16:07:34Z.


What

drawSnapshotTableSetTests in agc_driver_recorder_tests (the agc_draw_descriptors entry) reads past its own texel array:

  • Its T# describes a 4x4 32-bit float linear surface of 1024 bytes: that is the size of the read below, and the new check passes with a 1024-byte array.
  • The test backs it with a 64-byte std::array<float, width * height>.
  • ShaderResources reads the whole surface while it resolves the image tables (cachedTexture → ReadTextureSurface → GuestMemory::ReadCommitted), so the read takes 960 bytes of whatever globals follow the array.

An ANYPS5_ENABLE_ASAN build reports it as a global-buffer-overflow (READ of size 1024) and fails the test. A normal build reads the neighbouring bytes silently, and the test passes because it only counts descriptor writes.

The texels are now sized as in the next test in the file (width * height * (lastSlice + 1u) * 16u there, width * height * 16u here). The test also requires DescribeSurface(DecodeTextureResource(texture)).guestBytes <= sizeof(texels), as that test does, so a smaller array fails the test in any build. Only the test changes.

Tested

Ubuntu 24.04, GCC 13.3, NVIDIA RTX 4070 Ti, driver 595.99.02, on main cecb540a63.

  • ANYPS5_ENABLE_ASAN build (RelWithDebInfo, -fno-var-tracking, because GCC 13 crashes in its var-tracking pass on SpirvImageEmitter.cpp with ASan), agc_driver_recorder_tests --draw-descriptors-only:
    • main: fails 3 of 3, each with ERROR: AddressSanitizer: global-buffer-overflow ... READ of size 1024 in copyCommitted under drawSnapshotTableSetTests.
    • The new check alone, with the 64-byte array: fails with "the draw snapshot table set test T# reads past its texels", before any read, with no ASan report.
    • This change: passes 3 of 3, no ASan report.
    • All 54 ctest entries that run agc_driver_recorder_tests pass under ASan.
  • Normal test build: agc_draw_descriptors passes 3 of 3.

In the same ASan sweep of the CPU-side tests (1140), 5 other tests fail, none from this code:

  • the three net_dontwait_blocking_* tests, which #8917 and #8918 cover;

  • guest_unused_import_dependencies, whose subprocess stops because the ASan runtime is not first in its library list;

  • guest_backtrace ("first frame is not in the calling module"), which I haven't looked into.

  • Windows 11 Enterprise 26300, NVIDIA GeForce GT 1030 (driver 582.78), WinLibs GCC 15.2.0 r7 (UCRT), Release: agc_draw_descriptors passes 3 of 3 on main and 3 of 3 with this change. The table-set case runs there (the device has image tables) and passes.

Not tested: AMD, Intel (the change is to a test buffer's size).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 595.99.02, Ubuntu 24.04; NVIDIA GeForce GT 1030, driver 582.78, Windows 11
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4954626699 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9236). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-21T16:07:34Z. --- ### What `drawSnapshotTableSetTests` in `agc_driver_recorder_tests` (the `agc_draw_descriptors` entry) reads past its own texel array: - Its T# describes a 4x4 32-bit float linear surface of 1024 bytes: that is the size of the read below, and the new check passes with a 1024-byte array. - The test backs it with a 64-byte `std::array<float, width * height>`. - `ShaderResources` reads the whole surface while it resolves the image tables (`cachedTexture` → `ReadTextureSurface` → `GuestMemory::ReadCommitted`), so the read takes 960 bytes of whatever globals follow the array. An `ANYPS5_ENABLE_ASAN` build reports it as a `global-buffer-overflow` (`READ of size 1024`) and fails the test. A normal build reads the neighbouring bytes silently, and the test passes because it only counts descriptor writes. The texels are now sized as in the next test in the file (`width * height * (lastSlice + 1u) * 16u` there, `width * height * 16u` here). The test also requires `DescribeSurface(DecodeTextureResource(texture)).guestBytes <= sizeof(texels)`, as that test does, so a smaller array fails the test in any build. Only the test changes. ### Tested Ubuntu 24.04, GCC 13.3, NVIDIA RTX 4070 Ti, driver 595.99.02, on `main` cecb540a63. - `ANYPS5_ENABLE_ASAN` build (RelWithDebInfo, `-fno-var-tracking`, because GCC 13 crashes in its var-tracking pass on `SpirvImageEmitter.cpp` with ASan), `agc_driver_recorder_tests --draw-descriptors-only`: - `main`: fails 3 of 3, each with `ERROR: AddressSanitizer: global-buffer-overflow ... READ of size 1024` in `copyCommitted` under `drawSnapshotTableSetTests`. - The new check alone, with the 64-byte array: fails with "the draw snapshot table set test T# reads past its texels", before any read, with no ASan report. - This change: passes 3 of 3, no ASan report. - All 54 ctest entries that run `agc_driver_recorder_tests` pass under ASan. - Normal test build: `agc_draw_descriptors` passes 3 of 3. In the same ASan sweep of the CPU-side tests (1140), 5 other tests fail, none from this code: - the three `net_dontwait_blocking_*` tests, which #8917 and #8918 cover; - `guest_unused_import_dependencies`, whose subprocess stops because the ASan runtime is not first in its library list; - `guest_backtrace` ("first frame is not in the calling module"), which I haven't looked into. - Windows 11 Enterprise 26300, NVIDIA GeForce GT 1030 (driver 582.78), WinLibs GCC 15.2.0 r7 (UCRT), Release: `agc_draw_descriptors` passes 3 of 3 on `main` and 3 of 3 with this change. The table-set case runs there (the device has image tables) and passes. Not tested: AMD, Intel (the change is to a test buffer's size). ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 595.99.02, Ubuntu 24.04; NVIDIA GeForce GT 1030, driver 582.78, Windows 11 - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
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!9236
No description provided.