Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
xXPBSXx:fix/asan-skip-asan-lib
Nov 1, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
xXPBSXx:fix/asan-skip-asan-lib

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

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 (fix(tests): drop the guest_freebsd_clocks check that the host zone is UTC #12660, test(libkernel): pin the zone before the kernel timezone check #12747 and test(libkernel): initialize UTC for timezone assertion #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

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/CMakeLists.txt
PR 7275 core/libs/CMakeLists.txt
PR 8650 core/libs/CMakeLists.txt
PR 9156 core/libs/CMakeLists.txt
PR 9162 core/libs/CMakeLists.txt
PR 9293 core/libs/CMakeLists.txt
PR 9297 core/libs/CMakeLists.txt
PR 9302 core/libs/CMakeLists.txt
PR 9383 core/libs/CMakeLists.txt
PR 12642 core/libs/CMakeLists.txt
PR 13253 core/libs/CMakeLists.txt
PR 13256 core/libs/CMakeLists.txt

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@oneandonlydean
oneandonlydean merged commit ffb95fd into boykopovar:main Nov 1, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants