Skip to content

fix(tests): define the nothrow operator new in guest_cnd_at_thread_exit - #15463

Open
xXPBSXx wants to merge 1 commit into
boykopovar:mainfrom
xXPBSXx:fix/guest-cnd-at-thread-exit-nothrow-new
Open

xXPBSXx wants to merge 1 commit into
boykopovar:mainfrom
xXPBSXx:fix/guest-cnd-at-thread-exit-nothrow-new

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

What

The guest_cnd_at_thread_exit test fails in the Sanitizers nightly of 2026-11-03 (head f6232fc) with AddressSanitizer: alloc-dealloc-mismatch (operator new vs free) at Threads.cpp:222. The test replaces the global operator new(size_t) and both operator delete overloads with malloc and free, but not the nothrow overload. _Mtx_init_nid_postfix allocates its mutex with new (std::nothrow), which under ASan is still the sanitizer's operator, so the matching delete in _Mtx_destroy_nid_postfix reaches free. The test comes from #10615 (merged 2026-11-02).

This PR defines operator new(std::size_t, const std::nothrow_t&) in the test, using malloc and returning nullptr while failAllocations is set, like the throwing overload throws.

Changes one file, core/libs/tests/GuestCndAtThreadExit.cpp (+5).

Tested

  • Ubuntu 24.04 in WSL, GCC 13.3 with libasan 8, RelWithDebInfo, ANYPS5_ENABLE_ASAN=ON and -fsanitize=undefined -fno-sanitize=vptr (UBSan linked: libubsan.so.1 in the test's NEEDED list), on main d1ae628, whose GuestCndAtThreadExit.cpp and Threads.cpp are identical to the nightly head.
  • cmake exited 0 and ninja exited 0 (112 s).
  • Test unchanged (red): ctest -R '^guest_cnd_at_thread_exit$' failed in 2 of 2 runs with alloc-dealloc-mismatch ... _Mtx_destroy_nid_postfix ... Threads.cpp:222.
  • With the fix: ninja exited 0, and the same ctest passed in 3 of 3 runs.
  • python -I tools/check_conventions.py --base upstream/main passed and git diff --check is clean, on the rebased commit at main 4f41f4c.
  • Not run: Windows and macOS (ASan is Linux only). Nine other tests under core/libs/tests also define operator new(std::size_t…) without a nothrow overload (GuestAllocationsOom, GuestAmmPool, GuestJsonFloatFailure, GuestPoll, GuestSocketPair, Http2TeardownFailure, JsonCopyFailure, RudpPollWaitException, UltFinalizeAllocation); I did not run them under ASan, and only this one failed in the nightly.

Overlap

Checked against main 4f41f4c with the 1684 open PRs listed at 11:07 UTC; the changed files of each PR come from git diff --name-only against its merge base, finished 12:09 UTC. No PR changes GuestCndAtThreadExit.cpp. Four PRs opened after the listing (#15449 to #15452) had no fetchable ref; their file lists read through the API (3, 4, 11 and 7 files) do not include it either. Five PRs change libc/src/Threads.cpp (#12146, #9447, #7648, #5021, #1835); none of their hunks touches _Mtx_init or _Mtx_destroy, and this PR does not change Threads.cpp. git merge-tree of this head with main is clean. Depends on: none.

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>
@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head 3a8d6eb merged onto main 4f41f4c · tested 2026-11-03 13:31 UTC · 18 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 1,072 passed · 5 failed (0 new, 3 also fail on main, 2 unstable on main) · 6 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 1,083 of 3,811 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (524 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.1 s, ⚠️ public_headers 73.8 s, ⚠️ agc_driver_image_sample_unnormalized 42.2 s, ⚠️ agc_driver_lazy_resolved_abi 33.2 s
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 7 of the last 9 main runs
agc_driver_store_over_untracked: failed in 1 of the last 9 main runs
Failing on main too (3, not counted against this PR)
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_multisample_depth
Validation IDs already present on main (4 IDs in 446 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (446 tests): agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, agc_driver_bindless_images, and 438 more
VUID-vkCmdCopyImage-srcImage-01548 (8 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth, agc_driver_stencil_null_feedback, agc_driver_stencil_plane_memory
VUID-vkCmdCopyImage-srcImage-01551 (8 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth, agc_driver_stencil_null_feedback, agc_driver_stencil_plane_memory
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_srgb8_color_target
Skipped (6)
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
Reproduce
git fetch origin 3a8d6eb104841a0e775b3f38e26e95a06f475d2c 4f41f4c375f5abb487dbd184fbc150f31994d762
git checkout 4f41f4c375f5abb487dbd184fbc150f31994d762 && git merge --no-ff 3a8d6eb104841a0e775b3f38e26e95a06f475d2c
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

hugodearaujo added a commit to hugodearaujo/AnyPS5 that referenced this pull request Nov 6, 2026
…hread

The test replaces operator new and the operator delete overloads, and
its delete frees with std::free, but it left the std::nothrow_t forms of
operator new to the runtime. scePthreadAttrInit allocates with
new (std::nothrow), so under AddressSanitizer the attribute came from
ASan's allocator and went back to free through the test's delete, which
ASan reports as alloc-dealloc-mismatch. Allocate the nothrow forms with
std::malloc too, as boykopovar#15463 does for guest_cnd_at_thread_exit.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants