Repository navigation
test(libSceUlt): give the ulthread runtime of the sync test its 4096 bytes - #8772
Conversation
…bytes sceUltUlthreadRuntimeCreate clears 4096 bytes of the runtime object, and guest_ult_thread_tests already passes a 4096-byte runtime. The ulthreads case of guest_ult_sync_tests passed a 256-byte object, so the runtime creation wrote 3840 bytes past it on the stack. In a Windows Debug build the write runs off the top of the main thread stack and the test crashes with an access violation.
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed the runtime buffer contract against sceUltUlthreadRuntimeCreate and the existing guest_ult_thread_tests fixture: the runtime object needs 4096 writable bytes, and this focused test supplied only 256. The 4096-byte aligned wrapper is the narrow fix, with the reported Debug red/green runs and full-suite caveats stated clearly. Eligibility, conventions and intake checks pass.
MarcZX10
left a comment
There was a problem hiding this comment.
The test now gives sceUltUlthreadRuntimeCreate a 4096-byte, 8-byte-aligned object, matching the runtime size the implementation clears. The PR is narrowly scoped and the eligibility, conventions, intake, and labels checks pass. Build jobs are skipped for this test-only PR, so this approval is based on source inspection and those checks.
What
Fixes a crash in
guest_ult_sync_ulthreads(added by #8248) in a Windows Debug build. Onmainthe test dies with an access violation every time:addr2lineon the Debug binaries resolves the two return addresses tosceUltUlthreadRuntimeCreate(core/libs/prx/libSceUlt/Export.cpp:752,std::memset(runtime, 0, 4096)) and toUlthreads(core/libs/tests/GuestUltSync.cpp:277). The test passes its 256-byteObjectas the runtime, so creating the runtime writes 3840 bytes past it on the stack. In the Debug frame the object sits 0x520 bytes below the top of the main thread stack, so the write runs off the stack and faults. Release lays out the frame differently, so the overrun hits memory the test does not read afterwards, and the test passes there. That makes the bug undefined behaviour on every host, not only on Windows Debug.The library has cleared 4096 bytes of the runtime since
sceUltUlthreadRuntimeCreatewas first implemented (5ae2a810e), andguest_ult_thread_testsalready passes a 4096-byteRuntime(core/libs/tests/GuestUltThread.cpp:71). The change gives the sync test a 4096-byte runtime object next to its existing 512-byteUlthreadObject. The library and the other cases are unchanged.The same overrun aborts on macOS under the stack protector; the open macOS host PR #8658 wraps a 4096-byte runtime for this test in
#ifdef __APPLE__. This change fixes it for every host, so that hunk would no longer be needed.Tested
Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Ninja,
BUILD_TESTING=ON, every AGC execution test built.ctest --test-dir <Debug build> -R "^guest_ult_sync_ulthreads$": onmainit fails 3 of 3 with the access violation above (checked on9d5099f5e,339217ebcand5b59fbc55). With this change it passes 3 of 3.-R "^guest_ult_"passes 25 of 25 in Debug.ctest -R "^guest_ult_|patched_libraries"passes 26 of 26, with354 patched libraries loaded, 0 failed. The full Releasectest --parallel 2 --timeout 300withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1passes 1786 of 1787. The one failure is test(agc): align the array window test's texels at run time #8310'sagc_driver_image_array_window_past_layer_limit(Not Run, because it doesn't build with MinGW).thread_name(Debug link, fix(libc): link the thread-name test against libc for its personality routine #8635) and test(agc): align the array window test's texels at run time #8310's test.tools/check_conventions.py --base origin/mainandtools/check_test_registration.py(Release and Debug) pass.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)