test(agc): reserve the arena host hole the write-tracking checks query #4746

Merged
oneandonlydean merged 1 commit from upstream-pr/4746 into main 2026-10-12 21:08:48 +00:00
oneandonlydean commented 2026-10-12 20:34:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T20:34:59Z.


What

agc_driver_graphics fails now and then in the Windows job, on pull requests that do not touch the arena, and passes on a re-run:

AGC graphics: write-watched arena contained no host exclusion to test

Three of the runs: 38222544270, 38224130565, 38284199193 (first attempt of each).

The cause is the test, not the exclusion. On Windows the arena is reserved while libc loads, before any code of the test executable runs, and its host regions are whatever the process had already mapped in the arena interval at that moment. Where Windows places those mappings changes with every start, and on some starts none of them lies in the interval. The arena then has no host hole, and hostWriteWatchExclusionTests (#3594) requires one. #4660 counted 5 such starts in 200, and #4186 saw the same and made agc_write_tracking print that its host-hole checks were skipped. So today the host-hole exclusion is checked on most starts, fails one test on the others and is silently not checked by the second.

This change makes the hole exist on every start:

  • agc_write_tracking starts itself suspended with --host-hole, reserves one allocation granule in the middle of the child's arena interval with VirtualAllocEx, and resumes it. The child's loader has not run yet, so when its libc reserves the arena that range is already taken and becomes a host region.
  • The child requires that the range is an arena host region and runs the host-hole checks from #4186 on it, unchanged. The parent requires that the child exits with 0.
  • The enumeration of the arena for a hole, and the "skipped" line for the case that it finds none, are removed from agc_write_tracking.
  • The four queries hostWriteWatchExclusionTests made on an enumerated hole (Watched, CollectWritesUncached, UnchangedSince, UnchangedSinceAll) are removed from agc_driver_graphics: the child makes the same four and eight more. Its checks on ordinary host heap memory stay.

No production code changes.

#4660 is open for the same failure and replaces the Require with a printed line. That stops the failure; the exclusion is then still not checked on the starts without a hole. The two touch the same lines of BdaResources.cpp, so only one of them can go in.

Tested

Windows was not run: I have no Windows machine. Everything this change adds is inside #ifdef _WIN32, so the Windows job on this pull request is the test. agc_write_tracking has to pass there, and since the child fails when its range is not a host region, a pass means the hole was reserved and queried on that start. agc_driver_graphics can no longer fail with the message above, because the check is gone from it. A few re-runs of the Windows job would show it holds across address layouts.

Linux (CachyOS, GCC 16, Release, CI configure flags), on main 1acfa7f78:

  • agc_write_tracking_tests and agc_driver_graphics_tests build; ctest -R "agc_driver_graphics|agc_write_tracking" passes 2 of 2. On Linux the two files compile to what they did before, apart from one added include.
  • The Windows branch of WriteTracking.cpp and BdaResources.cpp was type-checked with g++ -fsyntax-only -D_WIN32 against Wine's Windows headers, with no errors or warnings. That checks names and types only; nothing was linked or run.
  • python3 tools/check_conventions.py --base origin/main and python3 tools/check_test_registration.py build pass; tools/tests/test_check_skips.py passes 13 of 13.

Not tested: that VirtualAllocEx on the suspended child succeeds on the CI runner, and that the child's arena reports the range as a host region. Both are read from the code (Arena() records every region that VirtualQuery reports as not free as a host region) and both are required by the test, so a wrong assumption fails the Windows job on every run instead of now and then.

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
  • Unblocks: none
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4834697092 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4746). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-12T20:34:59Z. --- ### What `agc_driver_graphics` fails now and then in the Windows job, on pull requests that do not touch the arena, and passes on a re-run: ``` AGC graphics: write-watched arena contained no host exclusion to test ``` Three of the runs: [38222544270](https://github.com/boykopovar/AnyPS5/actions/runs/38222544270), [38224130565](https://github.com/boykopovar/AnyPS5/actions/runs/38224130565), [38284199193](https://github.com/boykopovar/AnyPS5/actions/runs/38284199193) (first attempt of each). The cause is the test, not the exclusion. On Windows the arena is reserved while `libc` loads, before any code of the test executable runs, and its host regions are whatever the process had already mapped in the arena interval at that moment. Where Windows places those mappings changes with every start, and on some starts none of them lies in the interval. The arena then has no host hole, and `hostWriteWatchExclusionTests` (#3594) requires one. #4660 counted 5 such starts in 200, and #4186 saw the same and made `agc_write_tracking` print that its host-hole checks were skipped. So today the host-hole exclusion is checked on most starts, fails one test on the others and is silently not checked by the second. This change makes the hole exist on every start: - `agc_write_tracking` starts itself suspended with `--host-hole`, reserves one allocation granule in the middle of the child's arena interval with `VirtualAllocEx`, and resumes it. The child's loader has not run yet, so when its `libc` reserves the arena that range is already taken and becomes a host region. - The child requires that the range is an arena host region and runs the host-hole checks from #4186 on it, unchanged. The parent requires that the child exits with 0. - The enumeration of the arena for a hole, and the "skipped" line for the case that it finds none, are removed from `agc_write_tracking`. - The four queries `hostWriteWatchExclusionTests` made on an enumerated hole (`Watched`, `CollectWritesUncached`, `UnchangedSince`, `UnchangedSinceAll`) are removed from `agc_driver_graphics`: the child makes the same four and eight more. Its checks on ordinary host heap memory stay. No production code changes. #4660 is open for the same failure and replaces the `Require` with a printed line. That stops the failure; the exclusion is then still not checked on the starts without a hole. The two touch the same lines of `BdaResources.cpp`, so only one of them can go in. ### Tested Windows was not run: I have no Windows machine. Everything this change adds is inside `#ifdef _WIN32`, so the Windows job on this pull request is the test. `agc_write_tracking` has to pass there, and since the child fails when its range is not a host region, a pass means the hole was reserved and queried on that start. `agc_driver_graphics` can no longer fail with the message above, because the check is gone from it. A few re-runs of the Windows job would show it holds across address layouts. Linux (CachyOS, GCC 16, Release, CI configure flags), on `main` 1acfa7f78: - `agc_write_tracking_tests` and `agc_driver_graphics_tests` build; `ctest -R "agc_driver_graphics|agc_write_tracking"` passes 2 of 2. On Linux the two files compile to what they did before, apart from one added include. - The Windows branch of `WriteTracking.cpp` and `BdaResources.cpp` was type-checked with `g++ -fsyntax-only -D_WIN32` against Wine's Windows headers, with no errors or warnings. That checks names and types only; nothing was linked or run. - `python3 tools/check_conventions.py --base origin/main` and `python3 tools/check_test_registration.py build` pass; `tools/tests/test_check_skips.py` passes 13 of 13. Not tested: that `VirtualAllocEx` on the suspended child succeeds on the CI runner, and that the child's arena reports the range as a host region. Both are read from the code (`Arena()` records every region that `VirtualQuery` reports as not free as a host region) and both are required by the test, so a wrong assumption fails the Windows job on every run instead of now and then. ### 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 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] Unblocks: none - [x] AI-assisted: yes (Claude Code)
oneandonlydean commented 2026-10-12 20:35:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T20:35:09Z.


@kr4y4 this is an alternative to #4660 for the same failure: it plants the host hole in a child process, so the checks run on every start. I can't run Windows here. Could you run agc_write_tracking and agc_driver_graphics on this head with --repeat until-fail:50 or so, and say whether the child's output shows in the ctest log? If VirtualAllocEx into the suspended child or the host-region check fails there, it will fail on every run, not now and then.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132160936 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4746#issuecomment-6132160936). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-12T20:35:09Z. --- @kr4y4 this is an alternative to #4660 for the same failure: it plants the host hole in a child process, so the checks run on every start. I can't run Windows here. Could you run `agc_write_tracking` and `agc_driver_graphics` on this head with `--repeat until-fail:50` or so, and say whether the child's output shows in the ctest log? If `VirtualAllocEx` into the suspended child or the host-region check fails there, it will fail on every run, not now and then.
github-actions[bot] commented 2026-10-12 20:45:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T20:45:07Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4660 core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp L807-829
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132305188 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4746#issuecomment-6132305188). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T20:45:07Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4660 | `core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp` [L807-829](https://github.com/boykopovar/AnyPS5/blob/5f01c808219237ba9bdcbf02f6e1db5075fd61a9/core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp#L807-L829) | | |
kr4y4 commented 2026-10-12 21:07:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kr4y4 on 2026-10-12T21:07:24Z.


Windows run, since the description had none.

Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head 59db660f7 merged into main 42496c5e5.

  • agc_write_tracking passes with --repeat until-fail:100 on both GPUs, at about 0.17 s a run, and prints write tracking tests passed. So the VirtualAllocEx on the suspended child and the child's host-region check held on every start.
  • With the VirtualAllocEx call replaced locally by reserved = true, it fails on both GPUs with the range reserved before the arena is not an arena host region and then the host-hole child failed. So a pass does mean the hole was reserved and queried.
  • agc_driver_graphics passes on both GPUs with --repeat until-fail:3.
  • Full suite (ctest --timeout 120 --parallel 4): 1007 of 1007 on both GPUs.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132622925 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4746#issuecomment-6132622925). Originally posted by [kr4y4](https://github.com/kr4y4) on 2026-10-12T21:07:24Z. --- Windows run, since the description had none. Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head 59db660f7 merged into `main` 42496c5e5. - `agc_write_tracking` passes with `--repeat until-fail:100` on both GPUs, at about 0.17 s a run, and prints `write tracking tests passed`. So the `VirtualAllocEx` on the suspended child and the child's host-region check held on every start. - With the `VirtualAllocEx` call replaced locally by `reserved = true`, it fails on both GPUs with `the range reserved before the arena is not an arena host region` and then `the host-hole child failed`. So a pass does mean the hole was reserved and queried. - `agc_driver_graphics` passes on both GPUs with `--repeat until-fail:3`. - Full suite (`ctest --timeout 120 --parallel 4`): 1007 of 1007 on both GPUs. Written with AI assistance.
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!4746
No description provided.