test(agc): keep shader memory test tables inside one guest page #472

Merged
adriadam10 merged 1 commit from upstream-pr/472 into main 2026-10-04 02:41:47 +00:00
adriadam10 commented 2026-10-03 16:50:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-03T16:50:31Z.


What

Under AddressSanitizer agc_shader_memory stops with a stack-buffer-overflow in GuestMemory::Read. ShaderMemory::page reads guest memory a whole 4 KiB page at a time, which is right for guest memory, but the test hands it host stack arrays and separate statics as guest buffers, so the page read covers neighbouring objects and their redzones. After the first report ASan finds the same thing in two more places (a global-buffer-overflow in verifyTwoLaneUniformValues, a stack-buffer-underflow in main).

The guest-visible tables of those three tests now live in one page-aligned static struct each (alignas(4096)), so every page the reader touches belongs to a single object. The values and checks are unchanged; only where the tables live.

Tested

  • Linux (CachyOS), GCC 16. agc_shader_memory passes in the Release build and under AddressSanitizer (-fsanitize=address, RelWithDebInfo, default ASAN_OPTIONS apart from detect_leaks=0). On main it fails under ASan with the report above.
  • The other 36 agc_* tests already pass under ASan; agc_driver_pixel_helper_lanes fails on this machine with and without ASan, unrelated.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4728138765 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/472). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-03T16:50:31Z. --- ### What Under AddressSanitizer `agc_shader_memory` stops with a stack-buffer-overflow in `GuestMemory::Read`. `ShaderMemory::page` reads guest memory a whole 4 KiB page at a time, which is right for guest memory, but the test hands it host stack arrays and separate statics as guest buffers, so the page read covers neighbouring objects and their redzones. After the first report ASan finds the same thing in two more places (a global-buffer-overflow in `verifyTwoLaneUniformValues`, a stack-buffer-underflow in `main`). The guest-visible tables of those three tests now live in one page-aligned static struct each (`alignas(4096)`), so every page the reader touches belongs to a single object. The values and checks are unchanged; only where the tables live. ### Tested - Linux (CachyOS), GCC 16. `agc_shader_memory` passes in the Release build and under AddressSanitizer (`-fsanitize=address`, RelWithDebInfo, default `ASAN_OPTIONS` apart from `detect_leaks=0`). On `main` it fails under ASan with the report above. - The other 36 `agc_*` tests already pass under ASan; `agc_driver_pixel_helper_lanes` fails on this machine with and without ASan, unrelated. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
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!472
No description provided.