Skip to content

test(agc): let agc_driver_graphics_tests run through in an ASan build - #17680

Closed
StepFPV wants to merge 2 commits into
boykopovar:mainfrom
StepFPV:fix/agc-graphics-tests-asan
Closed

StepFPV wants to merge 2 commits into
boykopovar:mainfrom
StepFPV:fix/agc-graphics-tests-asan

Conversation

@StepFPV

@StepFPV StepFPV commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

What

Since the 2026-11-07 run (#9675 merged after the 2026-11-06 one) the Sanitizers nightly stops agc_driver_graphics, agc_driver_graphics_maps_fallback and agc_graphics_profile_draw (all three run agc_driver_graphics_tests) after about 3 s, before any sanitizer gets a say; the failures are tracked in #16813, where my 2026-11-09 comment has the first root cause. Two test-only changes are needed for the binary to run through in an ASan build; the second one only shows once the first is in.

The PS4 color slices sit above 40 bits in an ASan build. gcnColorSliceTests (added by #9675) takes its three slices from GuestHeapAlignForGpu and requires the block to sit below 2^40, the limit of the GCN CB_COLOR0_BASE register it programs. In an ASan build every guest allocation lives above that: GuestArena::GuestAddressOffset moves the arena to 0x100000000000 so it clears ASan's shadow gap (GuestArena.hpp:16, since #7866), and the PS4 decode has only the 32 bits of 0x318 shifted by 8 (State.cpp:2220), unlike the PS5 decode, which takes the high bits from 0x390 (State.cpp:2347). The test stops on AGC graphics: guest heap memory is beyond the 40-bit PS4 GPU address space. In a Linux ASan build it now maps its 48 KiB itself with MAP_FIXED_NOREPLACE, starting at 0x60000000 below ASan's low shadow and stepping by 4 GiB as #16020 proposes for GcnColorTarget.cpp, and unmaps it afterwards. The decode reads that memory through the driver's page check, so it has to be real, readable memory, not just an address. Every other build keeps the guest heap block.

The replaced operator new has no nothrow form. #17007 added a glibc-only operator new and operator delete to DepthSurfaceReuse.cpp, which is linked into the same binary, to count allocations. It did not replace operator new(std::size_t, const std::nothrow_t&). libstdc++ takes the temporary buffer of std::stable_sort from the nothrow new and gives it back through the sized delete, so with the first change in, the binary stops a few tests later in PlanVertexCopies (VertexInput.hpp:355, from vertexCopyTests):

ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free)
    #0 free
    #1 std::__detail::__return_temporary_buffer<unsigned long>
    ...
    #6 AgcDriver::Graphics::PlanVertexCopies(...) Graphics/include/VertexInput.hpp:355
allocated by thread T0 here:
    #0 operator new(unsigned long, std::nothrow_t const&)

The nothrow new now goes through the replaced one, the same way ShaderMemory.cpp does.

Tested

Ubuntu 26.04 container with the Sanitizers workflow's flags (GCC 15.2.0, -DANYPS5_ENABLE_ASAN=ON, -g1 -fsanitize=undefined -fno-sanitize=vptr, ASAN_OPTIONS=detect_leaks=0, UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1), agc_driver_graphics_tests on main 0dd2fffe35:

  • main: the three tests fail in about 3.3 s on the 40-bit message.
  • the first commit alone: the three tests fail in about 3.8 s on the alloc-dealloc-mismatch above.
  • both commits: agc_graphics_profile_draw 55.9 s, agc_driver_graphics 58.2 s and agc_driver_graphics_maps_fallback 58.3 s pass, with no sanitizer output.

Windows 11, WinLibs GCC 15.2.0 UCRT, Release, RTX 4080 SUPER: agc_graphics_profile_draw and agc_driver_graphics pass with both commits on 0dd2fffe35 (13.0 s and 12.5 s), as they did on main 990481cdbf (18.8 s and 18.3 s). The second commit is inside #ifdef __GLIBC__, so Windows does not compile it. tools/check_conventions.py --base upstream/main passes.

Not tested on macOS, where GuestAddressOffset is 0 and neither path changes.

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: NVIDIA RTX 4080 SUPER, Windows 11
  • AI-assisted: yes

🤖 Generated with Claude Code

StepFPV and others added 2 commits November 9, 2026 10:51
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
DepthSurfaceReuse.cpp replaces operator new and delete in the graphics
test binary on glibc, but not the nothrow new. libstdc++ takes the
temporary buffer of std::stable_sort from the nothrow new and returns it
through the sized delete, so in an ASan build PlanVertexCopies stops on
an alloc-dealloc-mismatch (operator new vs free). The nothrow new now
goes through the replaced one, as ShaderMemory.cpp does.

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

github-actions Bot commented Nov 9, 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 1368 core/libs/prx/libSceAgcDriver/tests/DepthSurfaceReuse.cpp
PR 1395 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6235 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6280 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6481 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6804 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7256 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7642 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 8246 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9356 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9387 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9748 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9895 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9915 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10049 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10193 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 11551 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 12855 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 13928 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 13929 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 14944 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 15548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 15570 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 17611 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp

@github-actions github-actions Bot added the agc libSceAgc* label Nov 9, 2026
@JJenkx

JJenkx commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Windows check of head a509dbb527, merged onto main 5c26d4f13c (9b81fe5b28, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2.0 UCRT r7, Release, with Vulkan hidden.

  • All 45 selected tests pass in 3 of 3 runs each, none skipped. None of them needs a GPU device.
The 45 tests

agc_address_copy_cap, agc_address_copy_cap_mirror, agc_address_copy_cap_remembered, agc_address_space_unwatched_mirror_import, agc_command_batch_fence_failure, agc_compute_descriptor_layout_flags, agc_copy_input_kept_bytes, agc_depth_copy_kept_bytes, agc_descriptor_cache, agc_descriptor_pool_reset_failure, agc_driver_address_space_teardown, agc_driver_alpha_to_coverage_state, agc_driver_covered_centroid_state, agc_driver_depth_bounds_state, agc_driver_fault_only_template_records, agc_driver_fault_only_template_records_kept, agc_driver_fault_only_template_records_loop_guard, agc_driver_fault_only_template_records_loop_guard_kept, agc_driver_linear_volume_nonresident, agc_driver_msaa_dcc_state, agc_driver_sample_location_grid_fallback, agc_driver_sample_order_planning, agc_driver_undithered_alpha_to_coverage_state, agc_driver_unobserved_provoking_vertex, agc_driver_unused_viewport_depth, agc_graphics_profile_draw, agc_heap_mirror_reference_size, agc_heap_mirror_run_unwatch, agc_heap_mirror_run_unwatch_no_space_cache, agc_heap_mirror_unwatch, agc_heap_mirror_unwatch_no_space_cache, agc_pipeline_journal, agc_pipeline_journal_extended_paths, agc_pipeline_journal_long_paths, agc_pipeline_library_clear_waits_for_build, agc_pipeline_store_fixed_bound, agc_pipeline_store_growth, agc_pipeline_store_lazy_buffer_pool, agc_pipeline_store_replay_growth, agc_pipeline_store_touch, agc_sparse_buffer_holes, agc_sparse_heap_mirror_budget, agc_sparse_heap_mirror_unwatch, agc_sparse_heap_mirror_unwatch_no_space_cache, guest_font_graphics

AI-assisted: yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants