fix(build): run the CPU-side tests in an ANYPS5_ENABLE_ASAN build #7147
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7147"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-17T13:55:33Z.
What
-DANYPS5_ENABLE_ASAN=ONbuilds, but its tests don't pass. The set below is the 849 tests outsideagc_driver_*,agc_vertex_barrier*,agc_shader*and the VideoOut tests, run withASAN_OPTIONS=detect_leaks=0. Onmain4827f36cb5with #7115 applied, 14 of them fail. Each failure comes from the ASan build itself, not from the code under test. No CI job runs these tests under ASan, so nothing catches this. #7062, #7096 and #7097 add one for the relinker tests only. With this PR, all 849 pass and ASan reports nothing.patched_libraries,guest_memory_lifetimeGuestAllocations.cpp) before remapping them anonymously. In an instrumented test executable those pages hold ASan's redzones around globals:global-buffer-overflow ... READ of size 4096 ... in backWritableImageAnonymously.memcpy.guest_thread_self,guest_pthread_stack,guest_kernel_is_stack,guest_kernel_stack_protect,guest_raise_exceptiondetect_stack_use_after_return, which is on by default on Linux, an instrumented local lives on ASan's fake stack instead.detect_stack_use_after_return=0.guest_kernel_is_stack0xFC00000000, but the ASan build moves the guest arena up by0x100000000000.guest_memory's arena check already does.fiberLargeContextEntryandCheckActiveContextcheck a local's address against the fiber's context, which fake stacks break.CheckActiveContextalso reads the fiber's stack word by word above that local, through the redzones of the frames on that stack:stack-buffer-overflow ... in CheckActiveContext.detect_stack_use_after_return=0, andCheckActiveContextis not instrumented.guest_module_args,guest_deferred_dependencies,guest_module_fini,loadexec_argumentsASan runtime does not come first in initial library list.verify_asan_link_order=0. Preloading libasan instead makesloadexec_argumentsabort. ASan's__cxa_throwinterceptor then comes before libc.prx's, and the unwind of the exception that LoadExec throws for a missing target, andGuestLoadExecHostcatches, aborts in_Unwind_Resume.guest_allocator_failuresRLIMIT_DATAto 128 MiB and then commits 300 GiB. ASan maps that commit's 37.5 GiB of shadow, which the limit refuses:AddressSanitizer failed to allocate 0x960002000 (40265326592) bytes ... (errno: 12).agc_multisample_guest_access(GPU)fmaskDecompressMsaaTestsasksaligned_allocfor 0x71000 bytes at a 64 KiB alignment. C11 requires the size to be a multiple of the alignment, and ASan rejects it.add_asan_test_options(test options)(top-levelCMakeLists.txt) appends toASAN_OPTIONSfor one test in an ASan build and does nothing otherwise. Non-ASan builds run the same code as before, except for the roundedaligned_allocsize.Leak detection is not covered. With ASan's default
detect_leaks=1, 73 tests fail, mostly Vulkan-driver and process-lifetime allocations. That is separate work.Tested
Ubuntu 24.04, GCC 13.3, RTX 4070 Ti (NVIDIA 595.99). ASan build:
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DANYPS5_ENABLE_ASAN=ON,ASAN_OPTIONS=detect_leaks=0,ctest -E '^agc_driver_|^agc_vertex_barrier|videoout|^agc_shader' -j6.main4827f36cb5+ #7115: 14 of 849 fail, the 14 tests in the table, with 4 ASan reports.agc_multisample_guest_accessfails withinvalid alignment requested in aligned_alloc.fiber,patched_librariesandguest_memory_lifetimepass 3 of 3. The head,1c9d9d6bc5, only moves the three relinkeradd_asan_test_optionslines belowguest_module_fini, away from where #6112 addsguest_preinit. After reconfiguring, those four Python-hosted tests carryverify_asan_link_order=0and pass.fibertest option and its attribute spelling (861107b45a): the 14 changed tests pass 3 of 3, and the same 849-test set passes 849 of 849. On the final head,fiberbuilds without warnings and passes 3 of 3.tools/check_conventions.pypasses.tools/pr_overlap.pycouldn't compare 16 open PRs that conflict withmain. None of their diffs changes the lines this PR touches. #6044 movesFiber.cpp,GuestAllocatorFailures.cppandGuestKernelIsStack.cppinto subfolders and edits the same CMake files, so whichever of the two merges second needs a rebase. I'll do it if it's this one. #6112's newguest_preinitloads the same instrumented host into Python, so it will needadd_asan_test_options(guest_preinit verify_asan_link_order=0)once both are in.Without #7115,
guest_oncealso aborts in the ASan build (guest address space arena exhausted). That fix is separate because it changes libkernel itself.Not checked: Clang's ASan, Windows and macOS (ASan builds are Linux-only).
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)guest_once)agc_multisample_guest_accessonly)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T14:35:00Z.
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.
CMakeLists.txtcore/libs/prx/libc/src/GuestAllocations.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppCMakeLists.txtcore/libs/prx/libc/src/GuestAllocations.cppcore/libs/prx/libkernel/CMakeLists.txtCMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libc/src/GuestAllocations.cppcore/libs/prx/libkernel/CMakeLists.txtcore/relinker/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppCMakeLists.txtcore/libs/prx/libSceFiber/CMakeLists.txtcore/libs/prx/libSceSystemService/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtcore/libs/tests/Fiber.cppcore/libs/tests/GuestAllocatorFailures.cppcore/libs/tests/GuestKernelIsStack.cppcore/relinker/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libc/src/GuestAllocations.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtcore/relinker/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libc/src/GuestAllocations.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cpp