test(ajm): use a synthetic AT9 block that stays inside the gradient table #2163

Merged
Zheorgyan merged 1 commit from upstream-pr/2163 into main 2026-10-09 21:43:43 +00:00
Zheorgyan commented 2026-10-09 10:27:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Zheorgyan on 2026-10-09T10:27:40Z.


What

guest_ajm fails on macOS, as mugurc reported on #1. the first mono block of TestMultichannelAt9, header 0x00 filled with 0x07, makes LibAtrac9 read a gradient end unit above 31, and CreateGradient then writes past Block::Gradient[31] into GradientMode and the fields after it. what the decoder reports as used for the 27-byte block depends on the compiler: 27 with GCC at -O1 and above, 24 with GCC at -O0 and with clang, 20 with the array widened to 48. on macOS the second frame is parsed from offset 24 and fails with ERR_UNPACK_GRAD_START_UNIT_OOB

filled with 0xA5 the block is still 27 bytes, decodes the same everywhere, stays in bounds and is audible. the overrun itself is in Block in shadps4-emu/ext-LibAtrac9 and in the upstream library, only a malformed block reaches it

Tested

  • the block alone through LibAtrac9, built with GCC 14 at -O0 to -O3 and with Apple clang for arm64 and x86-64 at -O0 and -O2. with 0x07 the four results above, with 0xA5 27 bytes for each of the 4 frames everywhere. -fsanitize=bounds,address reports the Gradient overrun for 0x07 and nothing for 0xA5
  • macOS 15.6.1 on an M1 Pro, x86-64 under Rosetta, on mugurc's macos-port at c3affc1c. guest_ajm aborts before and passes after
  • Linux, Ubuntu 24.04 in Docker, GCC 14.2. guest_ajm passes before and after
  • tools/check_conventions.py passes

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:4799181043 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2163). Originally posted by [Zheorgyan](https://github.com/Zheorgyan) on 2026-10-09T10:27:40Z. --- ### What `guest_ajm` fails on macOS, as mugurc reported on #1. the first mono block of `TestMultichannelAt9`, header `0x00` filled with `0x07`, makes LibAtrac9 read a gradient end unit above 31, and `CreateGradient` then writes past `Block::Gradient[31]` into `GradientMode` and the fields after it. what the decoder reports as used for the 27-byte block depends on the compiler: 27 with GCC at `-O1` and above, 24 with GCC at `-O0` and with clang, 20 with the array widened to 48. on macOS the second frame is parsed from offset 24 and fails with `ERR_UNPACK_GRAD_START_UNIT_OOB` filled with `0xA5` the block is still 27 bytes, decodes the same everywhere, stays in bounds and is audible. the overrun itself is in `Block` in shadps4-emu/ext-LibAtrac9 and in the upstream library, only a malformed block reaches it ### Tested - the block alone through LibAtrac9, built with GCC 14 at `-O0` to `-O3` and with Apple clang for arm64 and x86-64 at `-O0` and `-O2`. with `0x07` the four results above, with `0xA5` 27 bytes for each of the 4 frames everywhere. `-fsanitize=bounds,address` reports the `Gradient` overrun for `0x07` and nothing for `0xA5` - macOS 15.6.1 on an M1 Pro, x86-64 under Rosetta, on mugurc's `macos-port` at `c3affc1c`. `guest_ajm` aborts before and passes after - Linux, Ubuntu 24.04 in Docker, GCC 14.2. `guest_ajm` passes before and after - `tools/check_conventions.py` passes ### 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
MarcZX10 commented 2026-10-09 11:05:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T11:05:34Z.

Review: APPROVED


Reviewed the complete one-line fixture change and the reported sanitizer/platform runs. The replacement byte keeps this synthetic AT9 block within the decoder's gradient table and avoids exercising an out-of-bounds dependency path in this AJM test. The conventions check is green; I see no Build check on this PR, so this approval relies on the author's reported Linux/macOS runs.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5469210783 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2163#pullrequestreview-5469210783). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T11:05:34Z. **Review:** APPROVED --- Reviewed the complete one-line fixture change and the reported sanitizer/platform runs. The replacement byte keeps this synthetic AT9 block within the decoder's gradient table and avoids exercising an out-of-bounds dependency path in this AJM test. The conventions check is green; I see no Build check on this PR, so this approval relies on the author's reported Linux/macOS runs.
popcoder565 commented 2026-10-09 15:46:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:46:56Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head ed8bf0bd, merged onto main d70b8998 in one build with 38 other PRs that had no Windows run.

  • This PR's tests pass: guest_ajm. None of them reported skipping a case.
  • Full ctest in that build: 519 of 519. That needed local fixes to three other PRs in the batch that don't build or pass on Windows: #1611, #1796 and #1824 (reported there).

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6084279713 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2163#issuecomment-6084279713). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T15:46:56Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `ed8bf0bd`, merged onto `main` d70b8998 in one build with 38 other PRs that had no Windows run. - This PR's tests pass: `guest_ajm`. None of them reported skipping a case. - Full ctest in that build: 519 of 519. That needed local fixes to three other PRs in the batch that don't build or pass on Windows: #1611, #1796 and #1824 (reported there). No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
Dextroid17 commented 2026-10-09 15:57:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T15:57:36Z.

Review: COMMENTED


Linux negative control on the configuration where the failure actually appears (-O0), since the approvals so far rest on the author's reported runs plus a Release Windows run.

gcc 16.2.1, base d70b8998; only core/libs/tests/GuestAjm.cpp swapped between arms:

                              main       this PR
Debug  -O0  guest_ajm_tests   exit 134   exit 0
Release     guest_ajm_tests   exit 0     exit 0

On main at -O0 the abort is a Require(false) at GuestAjm.cpp:597 (DecodeAt9Superframe) — the same symptom the reporter of #2321 (test #331) saw: one frame decoded, 24 bytes of the 384 consumed. Release passes on both arms, so this is (as the body says) an -O0-only failure, which is why it is invisible to the Release CI.

Could not verify: macOS/arm64, and the Block::Gradient overrun itself (it is in the vendored LibAtrac9 and is not reached by the corrected block).

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5472408554 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2163#pullrequestreview-5472408554). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-09T15:57:36Z. **Review:** COMMENTED --- Linux negative control on the configuration where the failure actually appears (`-O0`), since the approvals so far rest on the author's reported runs plus a Release Windows run. gcc 16.2.1, base `d70b8998`; only `core/libs/tests/GuestAjm.cpp` swapped between arms: ``` main this PR Debug -O0 guest_ajm_tests exit 134 exit 0 Release guest_ajm_tests exit 0 exit 0 ``` On main at `-O0` the abort is a `Require(false)` at `GuestAjm.cpp:597` (`DecodeAt9Superframe`) — the same symptom the reporter of #2321 (test #331) saw: one frame decoded, 24 bytes of the 384 consumed. Release passes on both arms, so this is (as the body says) an `-O0`-only failure, which is why it is invisible to the Release CI. Could not verify: macOS/arm64, and the `Block::Gradient` overrun itself (it is in the vendored LibAtrac9 and is not reached by the corrected block). 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!2163
No description provided.