guest_raise_short_sleep: unhandled single step at Aps5RedirectedEntryStub on Windows #24358
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 einfachama on 2026-11-20T15:06:35Z.
What happens
guest_raise_short_sleepandguest_raise_short_sleep_without_wakestop after 3 to 53 delivered raises, without a check message. Almost every run ends with exit code0x80000004(STATUS_SINGLE_STEP). The single-step exception that ends the process is raised atAps5RedirectedEntryStub+0with the debug registers already cleared, soReturnBreakHandlerpasses it on.Title, test or build step
ctest
guest_raise_short_sleepandguest_raise_short_sleep_without_wake(core/libs/tests/GuestRaiseShortSleep.cpp, registered incore/libs/prx/libkernel/CMakeLists.txt:3166)AnyPS5 commit
Reproduced at
main0a025bd3c6, no pull requests on top.core/libs/prx/libkernel/System/src/Exception.cppand the test are unchanged at7fa48cd1c6; the line numbers below are from there.System
Windows 11 Pro 26H2 (10.0.26300), AMD Ryzen 7 5800X, MSYS2 UCRT64 GCC 16.2.0-7 (SEH), Release. GPU: NVIDIA GeForce RTX 4060, driver 621.24; the test uses no GPU.
Steps to reproduce
Each test stops after 1 to 4 s.
Log
Exit code:
0x80000004.A last-chance vectored exception handler, added to a local copy of the test, logs the exception the process ends with. All 4 runs logged the same values:
Napper+0x1bis the instruction aftercall sceKernelUsleep_nid_postfix(GuestRaiseShortSleep.cpp:23). That is the guest return addressArmReturnBreaksetsDr0to while the napper sleeps in host code.What was checked
How the logged values fit
core/libs/prx/libkernel/System/src/Exception.cpp:TryDeliver(:727) →ArmReturnBreak(:693) →SetReturnBreak(:667) setsDr0to the guest return address and enables it inDr7.DisarmReturnBreak(:846, :888) →RetireReturnBreak(:684) →SetReturnBreak(false)clearsDr0andDr7.TryDeliversuspends the napper, readsRip= the return address and classifies it as guest code. It then callsRedirect(:771), which setsRiptoAps5RedirectedEntryStub(:441). The check at :762 only covers the arm of the same raise (arm->entry != nullptr && delivery.context.Rip == arm->at). A new raise has no arm yet.Dr6has no hit bit, soReturnBreakHandler(:631) callsDisarmedReturnBreak. That accepts only aRiparmed on the thread (:603,ArmedOnThread:585), and the stub never is. The handler returnsEXCEPTION_CONTINUE_SEARCHand the process ends.Shown: the exception address and
Rip(the stub), the clearedDr0,Dr6andDr7, and that the redirected thread stood at the armed return address. Inferred: the order in step 2, that the breakpoint fired and the arm was retired before the user-mode dispatch. I have not traced the kernel side.0x80000004and 1 with0xc0000409. In an elevated full-j16run,guest_raise_short_sleepfailed the same way andguest_raise_short_sleep_without_wakepassed once. Elevation is not needed for the failure.0xc0000409run was not examined further; I have not shown it is the same race.windowsjob of themainpush build passes both tests in about 0.05 s each (run 44738270262). The Windows MSYS2 nightly passes them, exceptguest_raise_short_sleep_without_wakewith0xc0000409on 11-19 (run 44487917040).03722a1570), and libkernel and libc changed in 297 files since.Proposed change
In
TryDeliver, do not redirect a thread whoseRipis a return address armed on that thread (ArmedOnThread(GetThreadId(native), Rip), not only the current raise'sarm->at). Treat it like host code and retry. The pending debug exception is then raised at the armed address, whereDisarmedReturnBreakalready continues it. The change is a few lines, and this test reproduces the failure on every run on the host above.AI-assisted: yes