fix(libkernel): release event flag waiters when the pattern is set #4899
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4899"
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 EagleBearerYS on 2026-10-13T02:54:11Z.
What
sceKernelSetEventFlag(libkernel/EventFlag/src/EventFlag.cpp) only ORs the bits in and wakes the waiters. Each waiter checks the pattern again only once it runs, so anything that takes the bits first leaves it waiting:sceKernelClearEventFlagright after the set;The waiter then fails with
ETIMEDOUTor, without a timeout, never returns. A set followed by a clear (a pulse) therefore misses its waiter.Measured on
mainwith the newguest_event_flag_releasetest:Now the set releases every queued waiter whose condition the new pattern meets, before it returns:
SCE_OKand the pattern it was released with, even if the flag is cleared, cancelled or deleted before it runs again;sceKernelCancelEventFlag's waiter count and the single-waiterEPERMcheck count only threads that are still waiting.shadPS4 and fpPS4 both release waiters this way:
Set, adopted in shadPS4#4772, which "fixes random hangs in SotC" (Shadow of the Colossus);_sceKernelSetEventFlag.No AnyPS5 title is claimed. The new entry in
docs/dev/debt/libkernel.mdsays that the order and the result pattern are unverified on a console. It also says that the thread-priority attribute (0x02) is not modelled: waiters queue in arrival order, as in fpPS4.Tested
Windows 11 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT), Release,
-DBUILD_TESTING=ON, onmainat495bf91a0:guest_event_flag_release: 100 rounds of the pulse above. Each round requires the waiter to returnSCE_OKwith the pattern 1.main'sEventFlag.cppthe test aborts after 1.4 s, when a waiter's 1 s wait runs out. With the change it passes 20 runs in a row.core/libs/prx/libc/CMakeLists.txtandcore/libs/prx/libkernel/CMakeLists.txtthat build on Windows, the new test among them.tools/check_conventions.py --base origin/mainpasses.main'sEventFlag.cppthe test aborts after 1.1 s. With the change it passes 20 runs in a row.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)Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T06:42:58Z.
Windows test: head
a71d2da79merged onto currentmainea2bbefb2(clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release,-j2: full build 0 errors; ctest with the filterguest_event_flag_release: guest_event_flag_release passed (1 test(s), 0 failed);python tools/check_conventions.py --base upstream/mainpassed. I did not run the new tests againstmainwithout the change.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:36:32Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed