fix(build): do not build libSceAddressSanitizer in an ASan or TSan build #12894

Merged
xXPBSXx merged 1 commit from upstream-pr/12894 into main 2026-11-01 11:24:15 +00:00
xXPBSXx commented 2026-10-29 13:37:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-29T13:37:01Z.


What

An ANYPS5_ENABLE_ASAN or ANYPS5_ENABLE_TSAN build fails to compile libSceAddressSanitizer (added in #12106): its 301 stubs are extern "C" int functions, 204 of them named __asan_* and 55 __ubsan_*, and with a sanitizer enabled the compiler already declares functions of those names with other signatures, so it stops with "new declaration ... ambiguates built-in declaration" in Api.hpp. The nightly Sanitizers workflow fails with this error in its run of 29 October, the first one after the library was added (run 40813774822).

This skips the library in those two builds (core/libs/CMakeLists.txt, three lines, the same way libkernel leaves a target out under ANYPS5_ENABLE_ASAN). Other builds are unchanged and still build libSceAddressSanitizer.prx.

Alternatives: renaming the functions would change the export names of the 301 stubs, which are the names a title imports. -fpermissive does not help: with it GCC 13.3 turns the 95 declaration errors into warnings, but the 95 definition errors remain and the file still does not compile. Side effect: in an ASan or TSan build a title that imports libSceAddressSanitizer does not find it; before #12106 it did not exist there either.

Tested

  • Ubuntu 24.04 under WSL2 (a virtualised kernel, not bare-metal), GCC 13.3, ANYPS5_ENABLE_ASAN build with UBSan: on main 8efa579b15 the build of libSceAddressSanitizer fails with the error above (190 lines of it). With this change on the same main the build finishes with exit code 0, and ctest (without the AGC and video-out tests, setarch x86_64 -R) runs 1731 tests, 1721 passed. The 10 that failed are not in this area: six stop at UBSan's vptr check in the C++ exception runtime (the nightly workflow builds with -fno-sanitize=vptr), two at an out-of-bounds index in the FreeType submodule, one at a left shift of a negative value in the Vorbis submodule, and guest_freebsd_clocks, which assumes the host zone is UTC and passes with TZ=UTC0 (#12660, #12747 and #12809 already change it).
  • Same Ubuntu, ANYPS5_ENABLE_TSAN build: on main 8efa579b15 the build of libSceAddressSanitizer fails with the same error (190 lines). With this change the build of 135 thread-related test targets finishes with exit code 0 and the tests run; the ThreadSanitizer reports and failures there are in other code and not part of this change.
  • Same Ubuntu, normal build without a sanitizer, with this change: libSceAddressSanitizer.prx is built (ninja exit code 0), and ninja -t targets all lists the library there but not in the ASan or TSan build of this change.
  • Windows 10 Pro, MinGW-w64 GCC 15.2, Release, with this change (ninja exit code 0): libSceAddressSanitizer.prx is built.
  • check_conventions --base upstream/main passes, and git merge-tree against main is clean.
  • Not run: Clang, macOS, and the nightly workflow itself with this change.

Overlap

I took the changed files of each of the 1393 open PRs from git diff --name-only against its merge base: 34 change core/libs/CMakeLists.txt and none changes libSceAddressSanitizer/. git diff -U0 of those 34 shows no change to a line that names AddressSanitizer, ENABLE_ASAN or ENABLE_TSAN. git merge-tree of this head with each of them conflicts for 8, and all 8 already conflict with main on their own, so no real pair conflict remains. Re-checked when opening against the open PRs created since then: #12782 and #12778 also change core/libs/CMakeLists.txt, and both merge cleanly with this branch.

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

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5069025758 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12894). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-29T13:37:01Z. --- ### What An `ANYPS5_ENABLE_ASAN` or `ANYPS5_ENABLE_TSAN` build fails to compile `libSceAddressSanitizer` (added in #12106): its 301 stubs are `extern "C" int` functions, 204 of them named `__asan_*` and 55 `__ubsan_*`, and with a sanitizer enabled the compiler already declares functions of those names with other signatures, so it stops with "new declaration ... ambiguates built-in declaration" in `Api.hpp`. The nightly Sanitizers workflow fails with this error in its run of 29 October, the first one after the library was added ([run 40813774822](https://github.com/boykopovar/AnyPS5/actions/runs/40813774822)). This skips the library in those two builds (`core/libs/CMakeLists.txt`, three lines, the same way `libkernel` leaves a target out under `ANYPS5_ENABLE_ASAN`). Other builds are unchanged and still build `libSceAddressSanitizer.prx`. Alternatives: renaming the functions would change the export names of the 301 stubs, which are the names a title imports. `-fpermissive` does not help: with it GCC 13.3 turns the 95 declaration errors into warnings, but the 95 definition errors remain and the file still does not compile. Side effect: in an ASan or TSan build a title that imports `libSceAddressSanitizer` does not find it; before #12106 it did not exist there either. ### Tested - Ubuntu 24.04 under WSL2 (a virtualised kernel, not bare-metal), GCC 13.3, `ANYPS5_ENABLE_ASAN` build with UBSan: on `main` `8efa579b15` the build of `libSceAddressSanitizer` fails with the error above (190 lines of it). With this change on the same `main` the build finishes with exit code 0, and `ctest` (without the AGC and video-out tests, `setarch x86_64 -R`) runs 1731 tests, 1721 passed. The 10 that failed are not in this area: six stop at UBSan's `vptr` check in the C++ exception runtime (the nightly workflow builds with `-fno-sanitize=vptr`), two at an out-of-bounds index in the FreeType submodule, one at a left shift of a negative value in the Vorbis submodule, and `guest_freebsd_clocks`, which assumes the host zone is UTC and passes with `TZ=UTC0` (#12660, #12747 and #12809 already change it). - Same Ubuntu, `ANYPS5_ENABLE_TSAN` build: on `main` `8efa579b15` the build of `libSceAddressSanitizer` fails with the same error (190 lines). With this change the build of 135 thread-related test targets finishes with exit code 0 and the tests run; the ThreadSanitizer reports and failures there are in other code and not part of this change. - Same Ubuntu, normal build without a sanitizer, with this change: `libSceAddressSanitizer.prx` is built (ninja exit code 0), and `ninja -t targets all` lists the library there but not in the ASan or TSan build of this change. - Windows 10 Pro, MinGW-w64 GCC 15.2, Release, with this change (ninja exit code 0): `libSceAddressSanitizer.prx` is built. - `check_conventions --base upstream/main` passes, and `git merge-tree` against `main` is clean. - Not run: Clang, macOS, and the nightly workflow itself with this change. ### Overlap I took the changed files of each of the 1393 open PRs from `git diff --name-only` against its merge base: 34 change `core/libs/CMakeLists.txt` and none changes `libSceAddressSanitizer/`. `git diff -U0` of those 34 shows no change to a line that names AddressSanitizer, `ENABLE_ASAN` or `ENABLE_TSAN`. `git merge-tree` of this head with each of them conflicts for 8, and all 8 already conflict with `main` on their own, so no real pair conflict remains. Re-checked when opening against the open PRs created since then: #12782 and #12778 also change `core/libs/CMakeLists.txt`, and both merge cleanly with this branch. ### 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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jotitadev commented 2026-10-30 19:00:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-30T19:00:31Z.

Review: COMMENTED


Ran the nightly Sanitizers recipe with this PR on bare-metal Linux, since the PR notes that the workflow itself was not run.

Setup: Ubuntu 26.04, i7-8700 (bare-metal), GCC 15.2. Head e41323717a merged onto main 6a3afa4deb. Configure and run steps as in .github/workflows/sanitizers.yml: Release, -DANYPS5_ENABLE_ASAN=ON, -g1 -fsanitize=undefined -fno-sanitize=vptr, the same ANYPS5_AGC_EXECUTION_TESTS, cmake --build -- -k 0 and then --target libs, and ctest with ASAN_OPTIONS=detect_leaks=0, UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1, APS5_SKIP_TIMING_TESTS=1, --timeout 300 --parallel 4. The only differences: no ccache, and ctest with -E "^agc|gpu|vulkan|video_out" (1835 tests), because this machine's GPU was in use.

Without the PR (main 6a3afa4deb):

  • check_test_registration.py passes.
  • The build stops only at libSceAddressSanitizer/Export.cpp.o, with 190 lines of "ambiguates built-in declaration" from Api.hpp, the same error as the nightly.
  • 34 tests are Not Run: guest_freetype_* (22), guest_jxr_lookup* (7), guest_libressl_protocol(_nid), patched_libraries, host_libstdcxx_exception and net_ipv6only_patched.

With the PR:

  • Both build steps exit 0, and check_test_registration.py passes.
  • 1835 tests, 1833 pass, and none are Not Run. Of the 34 that were Not Run, 32 pass.
  • The other two, guest_freetype_module_properties and _nid, stop at UBSan 3rdparty/freetype/src/autofit/afglobal.c:254:54: index 65535 out of bounds for type 'AF_StyleClassRec *[88]'. The test leaves an invalid autofitter default-script set, which #13512 fixes.
  • With #13512 also merged: 1835 of 1835 pass, with no sanitizer report anywhere in the log.

So once this lands the nightly should see these two FreeType failures, and nothing else new, unless #13512 lands first.

precise_wait passes in both runs here (and 10 of 10 unchanged under ASan without the variable). With its 90 us bound lowered to 5 us in a local copy, it fails 5 of 5 without APS5_SKIP_TIMING_TESTS and with =0, and passes 5 of 5 with =1 ("Skipping strict median bound"). That is the behaviour #13325 relies on in the nightly.

Not run: Clang, the GPU and agc tests, and the workflow on the hosted runner.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5717317513 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12894#pullrequestreview-5717317513). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-30T19:00:31Z. **Review:** COMMENTED --- Ran the nightly Sanitizers recipe with this PR on bare-metal Linux, since the PR notes that the workflow itself was not run. **Setup:** Ubuntu 26.04, i7-8700 (bare-metal), GCC 15.2. Head `e41323717a` merged onto `main` `6a3afa4deb`. Configure and run steps as in `.github/workflows/sanitizers.yml`: Release, `-DANYPS5_ENABLE_ASAN=ON`, `-g1 -fsanitize=undefined -fno-sanitize=vptr`, the same `ANYPS5_AGC_EXECUTION_TESTS`, `cmake --build -- -k 0` and then `--target libs`, and ctest with `ASAN_OPTIONS=detect_leaks=0`, `UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1`, `APS5_SKIP_TIMING_TESTS=1`, `--timeout 300 --parallel 4`. The only differences: no ccache, and ctest with `-E "^agc|gpu|vulkan|video_out"` (1835 tests), because this machine's GPU was in use. **Without the PR (`main` `6a3afa4deb`):** - `check_test_registration.py` passes. - The build stops only at `libSceAddressSanitizer/Export.cpp.o`, with 190 lines of "ambiguates built-in declaration" from `Api.hpp`, the same error as the nightly. - 34 tests are Not Run: `guest_freetype_*` (22), `guest_jxr_lookup*` (7), `guest_libressl_protocol(_nid)`, `patched_libraries`, `host_libstdcxx_exception` and `net_ipv6only_patched`. **With the PR:** - Both build steps exit 0, and `check_test_registration.py` passes. - 1835 tests, 1833 pass, and none are Not Run. Of the 34 that were Not Run, 32 pass. - The other two, `guest_freetype_module_properties` and `_nid`, stop at UBSan `3rdparty/freetype/src/autofit/afglobal.c:254:54: index 65535 out of bounds for type 'AF_StyleClassRec *[88]'`. The test leaves an invalid autofitter `default-script` set, which #13512 fixes. - With #13512 also merged: 1835 of 1835 pass, with no sanitizer report anywhere in the log. So once this lands the nightly should see these two FreeType failures, and nothing else new, unless #13512 lands first. `precise_wait` passes in both runs here (and 10 of 10 unchanged under ASan without the variable). With its 90 us bound lowered to 5 us in a local copy, it fails 5 of 5 without `APS5_SKIP_TIMING_TESTS` and with `=0`, and passes 5 of 5 with `=1` ("Skipping strict median bound"). That is the behaviour #13325 relies on in the nightly. Not run: Clang, the GPU and `agc` tests, and the workflow on the hosted runner. 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!12894
No description provided.