fix(libkernel): keep host fault signals available on macOS #8477
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8477"
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 ycarogabriel-lgtm on 2026-10-20T13:22:38Z.
What
Keep synchronous host fault signals deliverable while
scePthreadCreatecreates a guest thread, and unblock them when the guest thread starts on macOS. The guest signal mask remains emulated by libkernel. This prevents a guest-created thread under Rosetta from inheriting a host mask that hidesSIGBUS/SIGSEGVwrite-watch faults.The focused test checks that the creator's host mask is restored and the guest worker can receive fault signals. This extracts the issue #1 finding by @Cloud-Multiplayer from the former integration PR #7332. No title run is claimed for this branch.
Tested
mainthroughf2d874c1fdinadefe80eea; resolved theThread.cppconflict while preserving both Windows pending-exception delivery and the macOS fault-signal mask behavior.python3 tools/check_conventions.py --base origin/main: passed.ctest --test-dir build-mac -R '^public_headers$' -j1 --output-on-failure: passed.mainremains blocked by existing host portability gaps:pthread_getattr_npandpthread_getcpuclockidinThread.cpp,st_atim/st_mtim/st_ctiminNativeStat.cpp,MFD_CLOEXECinSharedMemory.cpp, andsys/vfs.hinStdio.cpp. These errors prevent building the focused test on this base; the test has not been rerun locally after the merge.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-20T15:47:34Z.
Ran the new test standalone on Apple silicon, since the description says it could not run on this branch alone.
Machine: Apple M4 Pro (24 GB), macOS 27.0.1 (26A434), x86-64 under Rosetta 2, Apple clang 21.0.0, CMake 4.4.4, Ninja 1.13.2, Release,
CMAKE_OSX_ARCHITECTURES=x86_64, no Vulkan loader.Base: main does not build the libraries on macOS, so I used mugurc's
ci/macos-series-2at53db0badb, plus the three code commits of #7937 (c6f44a028,ca0068033,4e5dba2db: without themDirectMemory/Jit.cppstops onMFD_CLOEXEC), plus this PR'sf22b57083cherry-picked (applies cleanly).guest_pthread_host_fault_maskctest -j6, 1649 tests)f22b57083Thread.cppreverted to the base, test keptguest_pthread_host_fault_maskandprecise_waitThe 17 fail without the fix too (and again when rerun one by one with it), so they come from the base, not from this change.
precise_waitis a timing test that is flaky on this host under load.The 17 failures common to both runs
guest_math(does not compile: libc++ has nostd::cyl_bessel_j/std::cyl_neumann),guest_math_exact,guest_standard_streams,agc_write_tracking("a block the import window did not touch reads as written"),agc_performance_overlay_statistics,guest_sce_net,guest_ssl_transport_kernel,guest_ssl_transport_net,guest_memory_lifetime,guest_filesystem,guest_host_standard_error,guest_itimer(SIGALRM delivery to a guest handler not implemented),guest_shm_open,guest_poll,guest_socket_pair,guest_kernel_app_archive_mmap,guest_flexible_memory_declared.Not checked: a title with and without the fix (Planet of Lana stops on this base at a pixel shader that reads barycentrics, before any write-watch path matters), Linux and Windows (the change is
__APPLE__only), and the GPU suite without the fix (with it, 761 of 807 AGC and shader tests pass on MoltenVK 1.4.2, but I have no run without it to compare).AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-21T18:18:08Z.
A title that needs this fix: Stray (PPSA02100, v01.002.000, Unreal Engine 4) hangs twice on macOS without it, and gets past both with only
f22b57083added.Machine: Apple M4 Pro (24 GB), macOS 27.0.1, x86-64 under Rosetta 2, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0).
Build: #8658 (
0a6c0fdd2) + #9193 + #9263 + the macOSRTLD_GLOBALloader change now in #8658, Release.f22b57083f22b57083RegisterShader→VulkanDevice→PrepareImportWatch→decideImportWatch, during the import write-protection probehost imports resolve write protection: no (0 of 4 scratch pages ...)APS5_WRITE_WATCH_IMPORTS=unwatch), after about 3,400 shaders are preparedDriver::preparePacketMemory→GuestMemory::Write→storeOwn, inside the store to guest memorydevice does not support the depth bounds test(MoltenVK has nodepthBounds)Both hangs are a plain store to a write-watched page that never returns, which is what the description explains: the threads inherit a mask with
SIGSEGV/SIGBUSblocked, so the fault is never delivered. Each hang reproduced in two runs; the stacks are fromsample. God of War (PPSA28997) and Planet of Lana (PPSA19450) reach gameplay on the same stack without this fix, so Stray is the first title I have that depends on it.Not checked: the depth bounds stop and anything after it, Linux and Windows, the full CTest suite.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T07:06:02Z.
Review: COMMENTED
Tested head
fc9716dadmerged with currentmainon macOS. The fix works, but after the merge the PR's test makespublic_headersfail.Machine: Apple M2 Max (32 GB), macOS 27.2 (26B5112a), Apple clang 21.0.0, x86_64 Release under Rosetta 2 (
-DCMAKE_OSX_ARCHITECTURES=x86_64, Ninja,BUILD_TESTING=ON, Python 3.9 from Xcode).Base:
mainb986c11a34does not build the libraries on macOS by itself, so the tree is thatmainplus the open macOS build PRs (#10366, #7631, #10659, #10660, #11249, #11358, #10669, #10552, #7804, #10676, #11447, #11437) and #11554, plus #11705 (applied locally). Only this PR is toggled, withgit merge --no-commiton top.GuestPthreadHostFaultMask.cppdeclaresscePthreadCreateandscePthreadJoinitself. Since35cf8d56cd(canonical headers, 2026-10-24, after this branch's lastmainmerge137a8fab89),core/libs/prx/libkernel/include/Api.hppdeclares both, and thepublic_headersaudit allows only one declaration:The audit reads the source tree, so it should fail on every host, not only macOS. #9263 hit the same thing after it merged, and
mainfixed it in039408c144. The same change works here:With that change,
public_headersand the 64public_headers_compile_*batches pass (65/65), andguest_pthread_host_fault_maskpasses 3/3. I ran this in the tree above with this PR, #10876 and #9263 (plus039408c144) merged together, and in that tree the non-GPU suite (1374 tests) has no new failures against the base apart from the 65public_headers*tests, which pass with the change. The merge itself is clean.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.