fix(libkernel): mark a destroyed condition variable with 1 and accept destroying a null one, as measured on a PS5 #10177
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10177"
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 orezraey on 2026-10-23T12:02:34Z.
What
Destroyed condition variables measured on a retail PS5 (firmware 13.60) with homebrew probes calling
libkernel_sys.sprxfrom a payload process. The sources and console logs are in this gist (pcond,pcond2). Split from #10130; @BunnyFl confirmed the same results against firmware 13.42 in #10130.Destroyed condition variables.
scePthreadCondDestroystores 1 in the slot, FreeBSD libthr'sTHR_COND_DESTROYED.scePthreadCondWait,scePthreadCondTimedwait,scePthreadCondSignal,scePthreadCondBroadcastandscePthreadCondDestroythen all returnEINVAL(0x80020016), and so does each of them for a slot that holds 1. AnyPS5 stored 2 and treated a slot holding 1 as a condition object, so it read through address 1.Destroying an uninitialized slot (null) returns 0 and leaves it null. Before, it stored the destroyed marker. Signal, broadcast and wait on a null slot initialize it, as before.
Tested
main(f4aabbb122, with #9165):284884d40b. Kept #9165's new timed-lock entry and this PR's measuredscePthreadCondWaitentry inlibkernel.md.guest_pthread_destroyed_objects,guest_pthread_mutex_errors,guest_pthread_join_detachandguest_pthread_condattrpass three runs in a row on Windows (MinGW) and on Linux (WSL Ubuntu, GCC);public_headersaudit andcheck_conventionspass.Windows 11, MinGW (winlibs).
guest_pthread_destroyed_objectschecks the stored 1 and a null slot through destroy, signal and broadcast. It fails onmainand passes with the change.tools/check_conventions.pypasses.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 MarcZX10 on 2026-10-23T12:09:34Z.
Review: APPROVED
Reviewed the exact submitted head
a431d14efe8d970737861fc157ef36c47a0e4524. The destroyed marker now matches the reported firmware behavior, and null destroy leaves an uninitialized slot untouched; the regression covers both cases and verifies that signal/broadcast still lazily initialize null slots. The PR reports 17 condition/destroyed-object tests passing three times on Windows, and the policy checks (eligibility, conventions, intake, labels and report) pass. Product jobs are skipped by repository path policy, and I could not independently run the focused executable because this checkout has no configured build tree. I initially raised and then retracted a condition-lifetime concern after tracing the shared ownership and initialization mutex; that concern is not a blocker.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T12:38:46Z.
Review: COMMENTED
I checked the overlap warning against #9165. That PR adds a separate timed self-lock debt bullet; this PR updates the condition-wait entry and changes only
Cond.cppplus the destroyed-object regression. The implementation behavior is independent. If stale debt-file context causes a rebase conflict, preserve both entries; noDepends onrelationship is needed.