fix(libkernel): keep waiting while a raise target is inside a system call #8637
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8637"
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 billythemenace2 on 2026-10-20T19:36:10Z.
Requested by billy
What
Follow-up to #7652 and #8512. Since #8512, a raise redirects a target running host code once 50 ms have passed since the raise began. A target inside a system call that isn't a wait can stay there longer than that. One case is the
NtWriteFileof anfwritethat holds its stream lock. The redirect then runs the handler with the lock still held, which is the #7652 deadlock again.SONIC SUPERSTARS (PPSA06888) freezes at frame 67 on
main434e965d4this way. Its IL2CPP collector's raise was delivered atntdll!ZwWriteFile+20(twice in the log), and the stream lock stayed with the stopped thread.InSystemCall: the target stopped right after asyscallinstruction (0F 05) in ntdll. While the target is suspended, it reads only those two bytes, with the ntdll base warmed before the first suspend.RetryLimit. The ntdll waits inBlockedInWaitare still redirected in place, as before.Tested
Windows 11, Ryzen 7 7700, WinLibs GCC 15.2.0, Release,
main434e965d4:guest_raise_in_system_call: a scePthreadfwrites 64 KiB blocks into a 4 KiB pipe that a reader drains 4 KiB every 10 ms, so it sits inNtWriteFileholding the stream lock for about 160 ms per block. The handler waits until the main thread hasfputc'd to the same stream, and the test raises 10 times. Withmain'sException.cppit times out in 4 of 4 runs. With this change it passes in 4 of 4, in 0.5 s.guest_raise_exception(13.5-14.2 s),guest_raise_in_host_code,guest_raise_nested_sleepandguest_mutex_raise_exceptionpass, three runs each.native multisample stencil or depth format import is not implementedstop (#6300).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)main)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T19:51:55Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libkernel/System/src/Exception.cppL429docs/dev/debt/libkernel.mdL151-152Some 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.
core/libs/prx/libkernel/System/src/Exception.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/System/src/Exception.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/System/src/Exception.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/System/src/Exception.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/System/src/Exception.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdImported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T23:33:00Z.
Independent Windows run of this PR (data only).
Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against
main339217ebc9is clean. I built onlyguest_raise_in_system_call_tests;ctest -N -R guest_raise_in_system_calllists exactly one test.Results (3 runs each):
guest_raise_in_system_callpasses 3/3.core/libs/prx/libkernel/System/src/Exception.cppwith the version from the PR's merge base (434e965d46), then rebuilt. The test times out 3/3 (ctest TIMEOUT). I restored the PR'sException.cppafterwards.Not run: other platforms, the other raise-exception tests, the full repository CTest, and any title or console run.
AI-assisted (Claude Code).