fix(libSceAjm.native): guard LibAtrac9 BitReverse32/SignExtend32 against undefined shifts in the ATRAC9 decoder #9548

Merged
jotitadev merged 1 commit from upstream-pr/9548 into main 2026-10-25 18:04:00 +00:00
jotitadev commented 2026-10-22 01:39:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T01:39:30Z.


What

Building the full (non-relinker) tree with UndefinedBehaviorSanitizer and running any
ATRAC9 path aborts in the bundled LibAtrac9. Every ATRAC9 decoder init hits a
shift exponent 32 is too large for 32-bit type in BitReverse32, reached through
GenerateShuffleTable(0) during MDCT-table setup. Both shifts are undefined behaviour
that is benign on a normal x86-64 build (the result happens to be correct), but UBSan
aborts the process when -fno-sanitize-recover=undefined is set.

This PR guards the two undefined shifts in 3rdparty/LibAtrac9/C/src/utility.c through
core/libs/prx/libSceAjm.native/PatchLibAtrac9.cmake, in the same file(READ) /
string(FIND) guard / string(REPLACE) / file(WRITE) style already used there for
unpack.c, bit_reader.c and decinit.c. utility.c is now built from the patched
copy (CMakeLists.txt), and added to CMAKE_CONFIGURE_DEPENDS so the patch re-runs when
upstream changes. The string(FIND) guards fail the configure with a clear message if
the upstream code drifts.

The two bugs

1. BitReverse32 — shift by 32 (utility.c:14)

return value >> (32 - bitCount);   // bitCount == 0  ->  value >> 32  (UB)

decinit.c builds the shuffle tables for sizes 1 << 0 .. 1 << 8, so
GenerateShuffleTable(0) calls BitReverse32(0, 0), which evaluates value >> 32 on a
32-bit unsigned int (undefined). On x86-64 the shift count is masked to 32 & 31 == 0,
so the result is the correct bit-reverse of 0, i.e. 0; no functional impact on a
normal build. This fires on every ATRAC9 decoder initialization.

Fix (BitReverse32 of any value with bitCount == 0 is 0):

return bitCount ? value >> (32 - bitCount) : 0u;

2. SignExtend32 — signed left-shift overflow (utility.c:20)

const int shift = 8 * sizeof(int) - bits;
return (value << shift) >> shift;   // e.g. 77 << 25  ->  signed overflow (UB)

Left-shifting a signed int into/over the sign bit is undefined. This was previously
masked
: the process always aborted earlier at BitReverse32 during init, before any
frame was decoded, so SignExtend32 was never reached under UBSan. Once BitReverse32
is guarded, the decoders that actually decode audio (guest_ajm, ngs2_atrac9) reach
this shift and UBSan reports left shift of N places cannot be represented in type 'int'.

Fix (perform the shift on the unsigned value — defined wraparound — then reinterpret; the
subsequent arithmetic right shift of a signed value is implementation-defined, not UB, so
UBSan is satisfied and the sign-extension result is unchanged on normal builds):

return (int)((unsigned int)value << shift) >> shift;

Sanitizer output (before, from guest_audiodec)

3rdparty/LibAtrac9/C/src/utility.c:14:15: runtime error: shift exponent 32 is too large for 32-bit type 'unsigned int'
    #0 BitReverse32            3rdparty/LibAtrac9/C/src/utility.c:14
    #1 GenerateShuffleTable    core/libs/prx/libSceAjm.native/atrac9/decinit.c:170
    #2 InitMdctTables          core/libs/prx/libSceAjm.native/atrac9/decinit.c:143
    #3 InitDecoder             core/libs/prx/libSceAjm.native/atrac9/decinit.c:31
    #4 Audiodec::ValidAt9Config  core/libs/prx/libSceAudiodec/src/Codecs.cpp:335
    ...

Tested

Red → green

Environment: Ubuntu 26.04, GCC 15.2.0, -DCMAKE_BUILD_TYPE=RelWithDebInfo, full build
(not ANYPS5_RELINKER_ONLY), -DANYPS5_ENABLE_ASAN=ON plus
-fsanitize=undefined -fno-sanitize-recover=undefined -fno-sanitize=vptr (C++) and
-fsanitize=undefined -fno-sanitize-recover=undefined (C).

Before the fix, the four ATRAC9 tests all abort at utility.c:14:

atrac9_config_data ...............***Failed  (shift exponent 32 ... 'unsigned int')
guest_ajm ........................***Failed  (shift exponent 32 ... 'unsigned int')
guest_audiodec ...................***Failed  (shift exponent 32 ... 'unsigned int')
ngs2_atrac9 ......................***Failed  (shift exponent 32 ... 'unsigned int')
0% tests passed, 4 tests failed out of 4

After the fix, all four pass with no UBSan error:

atrac9_config_data ...............   Passed
guest_ajm ........................   Passed
guest_audiodec ...................   Passed
ngs2_atrac9 ......................   Passed
100% tests passed, 0 tests failed out of 4

Guarding only BitReverse32 makes guest_ajm and ngs2_atrac9 then abort at
utility.c:20 (the SignExtend32 UB described above); guarding both makes the whole
ajm / audiodec / ngs2 / atrac9 set green under UBSan (19/19). The normal build
(no sanitizers) still compiles and those four tests pass.

Minimal reproduction (bug 1)

unsigned int BitReverse32(unsigned int value, int bitCount) {
    value = ((value & 0xaaaaaaaa) >> 1) | ((value & 0x55555555) << 1);
    value = ((value & 0xcccccccc) >> 2) | ((value & 0x33333333) << 2);
    value = ((value & 0xf0f0f0f0) >> 4) | ((value & 0x0f0f0f0f) << 4);
    value = ((value & 0xff00ff00) >> 8) | ((value & 0x00ff00ff) << 8);
    value = (value >> 16) | (value << 16);
    return value >> (32 - bitCount);
}
int main(void) { return (int)BitReverse32(0, 0); }   // GenerateShuffleTable(0)
$ gcc -fsanitize=undefined -fno-sanitize-recover=undefined r.c -o r && ./r
r.c:...: runtime error: shift exponent 32 is too large for 32-bit type 'unsigned int'

AI-assisted (Claude Code); the builds and tests above were run on my machine.

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: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4960789383 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9548). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T01:39:30Z. --- ### What Building the full (non-relinker) tree with UndefinedBehaviorSanitizer and running any ATRAC9 path aborts in the bundled LibAtrac9. Every ATRAC9 decoder init hits a `shift exponent 32 is too large for 32-bit type` in `BitReverse32`, reached through `GenerateShuffleTable(0)` during MDCT-table setup. Both shifts are undefined behaviour that is benign on a normal x86-64 build (the result happens to be correct), but UBSan aborts the process when `-fno-sanitize-recover=undefined` is set. This PR guards the two undefined shifts in `3rdparty/LibAtrac9/C/src/utility.c` through `core/libs/prx/libSceAjm.native/PatchLibAtrac9.cmake`, in the same `file(READ)` / `string(FIND)` guard / `string(REPLACE)` / `file(WRITE)` style already used there for `unpack.c`, `bit_reader.c` and `decinit.c`. `utility.c` is now built from the patched copy (`CMakeLists.txt`), and added to `CMAKE_CONFIGURE_DEPENDS` so the patch re-runs when upstream changes. The `string(FIND)` guards fail the configure with a clear message if the upstream code drifts. **The two bugs** **1. `BitReverse32` — shift by 32 (`utility.c:14`)** ```c return value >> (32 - bitCount); // bitCount == 0 -> value >> 32 (UB) ``` `decinit.c` builds the shuffle tables for sizes `1 << 0 .. 1 << 8`, so `GenerateShuffleTable(0)` calls `BitReverse32(0, 0)`, which evaluates `value >> 32` on a 32-bit `unsigned int` (undefined). On x86-64 the shift count is masked to `32 & 31 == 0`, so the result is the correct bit-reverse of `0`, i.e. `0`; no functional impact on a normal build. This fires on **every** ATRAC9 decoder initialization. Fix (`BitReverse32` of any value with `bitCount == 0` is `0`): ```c return bitCount ? value >> (32 - bitCount) : 0u; ``` **2. `SignExtend32` — signed left-shift overflow (`utility.c:20`)** ```c const int shift = 8 * sizeof(int) - bits; return (value << shift) >> shift; // e.g. 77 << 25 -> signed overflow (UB) ``` Left-shifting a signed `int` into/over the sign bit is undefined. This was **previously masked**: the process always aborted earlier at `BitReverse32` during init, before any frame was decoded, so `SignExtend32` was never reached under UBSan. Once `BitReverse32` is guarded, the decoders that actually decode audio (`guest_ajm`, `ngs2_atrac9`) reach this shift and UBSan reports `left shift of N places cannot be represented in type 'int'`. Fix (perform the shift on the unsigned value — defined wraparound — then reinterpret; the subsequent arithmetic right shift of a signed value is implementation-defined, not UB, so UBSan is satisfied and the sign-extension result is unchanged on normal builds): ```c return (int)((unsigned int)value << shift) >> shift; ``` **Sanitizer output (before, from `guest_audiodec`)** ``` 3rdparty/LibAtrac9/C/src/utility.c:14:15: runtime error: shift exponent 32 is too large for 32-bit type 'unsigned int' #0 BitReverse32 3rdparty/LibAtrac9/C/src/utility.c:14 #1 GenerateShuffleTable core/libs/prx/libSceAjm.native/atrac9/decinit.c:170 #2 InitMdctTables core/libs/prx/libSceAjm.native/atrac9/decinit.c:143 #3 InitDecoder core/libs/prx/libSceAjm.native/atrac9/decinit.c:31 #4 Audiodec::ValidAt9Config core/libs/prx/libSceAudiodec/src/Codecs.cpp:335 ... ``` ### Tested **Red → green** Environment: Ubuntu 26.04, GCC 15.2.0, `-DCMAKE_BUILD_TYPE=RelWithDebInfo`, full build (not `ANYPS5_RELINKER_ONLY`), `-DANYPS5_ENABLE_ASAN=ON` plus `-fsanitize=undefined -fno-sanitize-recover=undefined -fno-sanitize=vptr` (C++) and `-fsanitize=undefined -fno-sanitize-recover=undefined` (C). Before the fix, the four ATRAC9 tests all abort at `utility.c:14`: ``` atrac9_config_data ...............***Failed (shift exponent 32 ... 'unsigned int') guest_ajm ........................***Failed (shift exponent 32 ... 'unsigned int') guest_audiodec ...................***Failed (shift exponent 32 ... 'unsigned int') ngs2_atrac9 ......................***Failed (shift exponent 32 ... 'unsigned int') 0% tests passed, 4 tests failed out of 4 ``` After the fix, all four pass with no UBSan error: ``` atrac9_config_data ............... Passed guest_ajm ........................ Passed guest_audiodec ................... Passed ngs2_atrac9 ...................... Passed 100% tests passed, 0 tests failed out of 4 ``` Guarding only `BitReverse32` makes `guest_ajm` and `ngs2_atrac9` then abort at `utility.c:20` (the `SignExtend32` UB described above); guarding both makes the whole `ajm` / `audiodec` / `ngs2` / `atrac9` set green under UBSan (**19/19**). The normal build (no sanitizers) still compiles and those four tests pass. **Minimal reproduction (bug 1)** ```c unsigned int BitReverse32(unsigned int value, int bitCount) { value = ((value & 0xaaaaaaaa) >> 1) | ((value & 0x55555555) << 1); value = ((value & 0xcccccccc) >> 2) | ((value & 0x33333333) << 2); value = ((value & 0xf0f0f0f0) >> 4) | ((value & 0x0f0f0f0f) << 4); value = ((value & 0xff00ff00) >> 8) | ((value & 0x00ff00ff) << 8); value = (value >> 16) | (value << 16); return value >> (32 - bitCount); } int main(void) { return (int)BitReverse32(0, 0); } // GenerateShuffleTable(0) ``` ``` $ gcc -fsanitize=undefined -fno-sanitize-recover=undefined r.c -o r && ./r r.c:...: runtime error: shift exponent 32 is too large for 32-bit type 'unsigned int' ``` AI-assisted (Claude Code); the builds and tests above were run on my machine. ### 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: n/a - [x] AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-10-22 01:47:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:47:46Z.

Review: CHANGES_REQUESTED


The sanitizer diagnosis and the guarded patch approach are clearly described, and the two replacements match the exact upstream snippets they intend to change. However, the current hosted Conventions check fails with three required-template errors: sections What, Tested, and Checklist are missing or empty. Please move the existing summary and test evidence under the repository template headings and fill out the checklist, including the AI-assisted: yes item, then rerun conventions. The other current policy checks pass; product and relinker jobs were skipped by path policy. I have not run a local build or sanitizer suite; the 19/19 UBSan results are author-reported.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608335837 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9548#pullrequestreview-5608335837). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:47:46Z. **Review:** CHANGES_REQUESTED --- The sanitizer diagnosis and the guarded patch approach are clearly described, and the two replacements match the exact upstream snippets they intend to change. However, the current hosted Conventions check fails with three required-template errors: sections `What`, `Tested`, and `Checklist` are missing or empty. Please move the existing summary and test evidence under the repository template headings and fill out the checklist, including the `AI-assisted: yes` item, then rerun conventions. The other current policy checks pass; product and relinker jobs were skipped by path policy. I have not run a local build or sanitizer suite; the 19/19 UBSan results are author-reported.
MarcZX10 commented 2026-10-22 01:53:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:53:50Z.

Review: CHANGES_REQUESTED


The current Conventions run still fails with three required-template errors: sections What, Tested and Checklist are missing or empty. Please move the existing summary and sanitizer evidence into the required ### What and ### Tested sections, restore the full checklist from the repository template, and complete every item including Depends on, Unblocks, GPUs tested and AI-assisted. The current body contains useful UBSan evidence, but the project checker cannot recognize it in the present free-form layout.

Hosted eligibility, intake, labels and report checks pass. The required Conventions check fails; product/relinker jobs are skipped, and I did not run local tests. The reported UBSan results are author-reported.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608372465 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9548#pullrequestreview-5608372465). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:53:50Z. **Review:** CHANGES_REQUESTED --- The current Conventions run still fails with three required-template errors: sections `What`, `Tested` and `Checklist` are missing or empty. Please move the existing summary and sanitizer evidence into the required `### What` and `### Tested` sections, restore the full checklist from the repository template, and complete every item including `Depends on`, `Unblocks`, `GPUs tested` and `AI-assisted`. The current body contains useful UBSan evidence, but the project checker cannot recognize it in the present free-form layout. Hosted eligibility, intake, labels and report checks pass. The required Conventions check fails; product/relinker jobs are skipped, and I did not run local tests. The reported UBSan results are author-reported.
MarcZX10 commented 2026-10-22 01:53:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:53:51Z.


The newest Conventions run still reports What, Tested and Checklist as missing or empty. Please preserve your detailed sanitizer report but put it under the required template headings and fill every checklist line, including AI-assisted and applicable dependencies/unblocks/GPU fields. Eligibility, intake, labels and report pass; product/relinker jobs are skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330784439 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9548#issuecomment-6330784439). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:53:51Z. --- The newest Conventions run still reports `What`, `Tested` and `Checklist` as missing or empty. Please preserve your detailed sanitizer report but put it under the required template headings and fill every checklist line, including AI-assisted and applicable dependencies/unblocks/GPU fields. Eligibility, intake, labels and report pass; product/relinker jobs are skipped.
jotitadev commented 2026-10-22 04:28:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T04:28:29Z.


Thanks, moved the sanitizer report under What / Tested and filled every checklist line (Depends on, Fixes, Unblocks, GPUs tested, AI-assisted). Same for #9570.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6332710893 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9548#issuecomment-6332710893). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T04:28:29Z. --- Thanks, moved the sanitizer report under `What` / `Tested` and filled every checklist line (Depends on, Fixes, Unblocks, GPUs tested, AI-assisted). Same for #9570.
fogydes commented 2026-10-22 08:12:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-22T08:12:56Z.


The Conventions check fails on the head of this PR (job 119589122291): Fill in the pull request template: section 'What' is missing or empty, and the same for Tested and Checklist.

The relinker, relinker-asan, register-context and write-watch jobs all pass on the same commit, and python3 tools/check_conventions.py --base origin/main prints the same three template findings locally. Filling in every line of .github/pull_request_template.md (What, Tested, Depends on, Unblocks, GPUs tested, AI-assisted, and tick the boxes) is all that appears to block CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336033860 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9548#issuecomment-6336033860). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-22T08:12:56Z. --- The Conventions check fails on the head of this PR ([job 119589122291](https://github.com/boykopovar/AnyPS5/actions/runs/39706950809/job/119589122291)): `Fill in the pull request template: section 'What' is missing or empty`, and the same for `Tested` and `Checklist`. The relinker, relinker-asan, register-context and write-watch jobs all pass on the same commit, and `python3 tools/check_conventions.py --base origin/main` prints the same three template findings locally. Filling in every line of `.github/pull_request_template.md` (What, Tested, Depends on, Unblocks, GPUs tested, AI-assisted, and tick the boxes) is all that appears to block CI.
jotitadev commented 2026-10-22 08:27:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T08:27:38Z.


Thanks. That job ran on the old body; the body now follows the template and Conventions passes on the same head: https://github.com/boykopovar/AnyPS5/actions/runs/39722568967/job/119639159960

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336304063 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9548#issuecomment-6336304063). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T08:27:38Z. --- Thanks. That job ran on the old body; the body now follows the template and Conventions passes on the same head: https://github.com/boykopovar/AnyPS5/actions/runs/39722568967/job/119639159960
MarcZX10 commented 2026-10-22 11:30:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:30:35Z.


The template update is now reflected by a passing hosted conventions check. I ran the PR CMake patch script against its pinned LibAtrac9 submodule and compiled the generated utility.c with UBSan; a local boundary harness passed BitReverse32 at bit counts 0–32 and SignExtend32 across boundary patterns 1–32. The 19/19 full sanitizer results remain author-reported. I checked the #6044 overlap manually: its libSceAjm.native/CMakeLists.txt changes are in the test-registration block, while this PR changes configure dependencies and the atrac9 source list; the combined branch merge is text-clean and no ordering dependency appears necessary. Current main is 4777caca34; this head is 1 ahead/116 behind (merge base 94fbb8cea). Diff-check and conventions pass, and the merge with main is clean. Please update to current main and rerun the four ATRAC9 UBSan tests before merge. Product builds are skipped; I did not run the full runtime build locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339667677 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9548#issuecomment-6339667677). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:30:35Z. --- The template update is now reflected by a passing hosted conventions check. I ran the PR CMake patch script against its pinned LibAtrac9 submodule and compiled the generated `utility.c` with UBSan; a local boundary harness passed `BitReverse32` at bit counts 0–32 and `SignExtend32` across boundary patterns 1–32. The 19/19 full sanitizer results remain author-reported. I checked the #6044 overlap manually: its `libSceAjm.native/CMakeLists.txt` changes are in the test-registration block, while this PR changes configure dependencies and the `atrac9` source list; the combined branch merge is text-clean and no ordering dependency appears necessary. Current main is 4777caca34; this head is 1 ahead/116 behind (merge base 94fbb8cea). Diff-check and conventions pass, and the merge with main is clean. Please update to current main and rerun the four ATRAC9 UBSan tests before merge. Product builds are skipped; I did not run the full runtime build locally.
MarcZX10 commented 2026-10-22 11:30:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:30:37Z.

Review: DISMISSED


The formatting issue from my prior review is resolved. The source patch and updated CMake wiring look coherent; locally I ran the PR patch script against the pinned LibAtrac9 submodule and UBSan-tested the generated utility.c boundary cases successfully. The reported full sanitizer suite is author-reported. The #6044 CMake overlap is in a separate test-registration block and merges text-cleanly, so I found no sequencing requirement. I am retaining changes requested for the repository freshness requirement: this branch is 1 ahead/116 behind current upstream/main 4777caca34 (merge base 94fbb8cea). Please update and rerun the four ATRAC9 tests under UBSan on the resulting head. Diff-check and conventions pass on the current head; product builds are skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5613462771 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9548#pullrequestreview-5613462771). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:30:37Z. **Review:** DISMISSED --- The formatting issue from my prior review is resolved. The source patch and updated CMake wiring look coherent; locally I ran the PR patch script against the pinned LibAtrac9 submodule and UBSan-tested the generated `utility.c` boundary cases successfully. The reported full sanitizer suite is author-reported. The #6044 CMake overlap is in a separate test-registration block and merges text-cleanly, so I found no sequencing requirement. I am retaining changes requested for the repository freshness requirement: this branch is 1 ahead/116 behind current upstream/main 4777caca34 (merge base 94fbb8cea). Please update and rerun the four ATRAC9 tests under UBSan on the resulting head. Diff-check and conventions pass on the current head; product builds are skipped.
jotitadev commented 2026-10-22 12:53:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T12:53:07Z.


Rebased onto current main (8b3a6ba88d, which is past 4777caca34). New head: fcf6dece99 (1 commit, diff unchanged).

Rerun on the new head: Ubuntu 26.04, GCC 15.2.0, fresh full build (not ANYPS5_RELINKER_ONLY):

cmake -S . -B build-ubsan -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DANYPS5_ENABLE_ASAN=ON -DBUILD_TESTING=ON \
  "-DCMAKE_CXX_FLAGS=-fsanitize=undefined -fno-sanitize-recover=undefined -fno-sanitize=vptr" \
  "-DCMAKE_C_FLAGS=-fsanitize=undefined -fno-sanitize-recover=undefined"
cmake --build build-ubsan
ctest -R "^(atrac9_config_data|guest_ajm|guest_audiodec|ngs2_atrac9)$" --output-on-failure
atrac9_config_data ...............   Passed
guest_ajm ........................   Passed
guest_audiodec ...................   Passed
ngs2_atrac9 ......................   Passed
100% tests passed, 0 tests failed out of 4

The wider ajm|audiodec|ngs2|atrac9 set is also green under UBSan (18/18, excluding atrac9_gradient).

Side note, not caused by this PR: with these sanitizer flags tests/atrac9_gradient_tests fails to link (undefined reference to symbol 'pow@@GLIBC_2.29', DSO missing). The test includes unpack.c, which pulls band_extension.c.o from libatrac9.a via the Bex* tables, and that target does not link m (unlike atrac9_config_data_tests). This PR does not touch that target, unpack.c or band_extension.c; the plain Release build links it fine.

Written with AI assistance (Claude Code).
I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6341229997 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9548#issuecomment-6341229997). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T12:53:07Z. --- Rebased onto current `main` (`8b3a6ba88d`, which is past `4777caca34`). New head: `fcf6dece99` (1 commit, diff unchanged). Rerun on the new head: Ubuntu 26.04, GCC 15.2.0, fresh full build (not `ANYPS5_RELINKER_ONLY`): ``` cmake -S . -B build-ubsan -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DANYPS5_ENABLE_ASAN=ON -DBUILD_TESTING=ON \ "-DCMAKE_CXX_FLAGS=-fsanitize=undefined -fno-sanitize-recover=undefined -fno-sanitize=vptr" \ "-DCMAKE_C_FLAGS=-fsanitize=undefined -fno-sanitize-recover=undefined" cmake --build build-ubsan ctest -R "^(atrac9_config_data|guest_ajm|guest_audiodec|ngs2_atrac9)$" --output-on-failure ``` ``` atrac9_config_data ............... Passed guest_ajm ........................ Passed guest_audiodec ................... Passed ngs2_atrac9 ...................... Passed 100% tests passed, 0 tests failed out of 4 ``` The wider `ajm|audiodec|ngs2|atrac9` set is also green under UBSan (18/18, excluding `atrac9_gradient`). Side note, not caused by this PR: with these sanitizer flags `tests/atrac9_gradient_tests` fails to link (`undefined reference to symbol 'pow@@GLIBC_2.29'`, DSO missing). The test includes `unpack.c`, which pulls `band_extension.c.o` from `libatrac9.a` via the `Bex*` tables, and that target does not link `m` (unlike `atrac9_config_data_tests`). This PR does not touch that target, `unpack.c` or `band_extension.c`; the plain Release build links it fine. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
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!9548
No description provided.