libkernel: scePthreadJoin on self and scePthreadJoin/Detach on a null thread throw instead of returning EDEADLK/EINVAL; fix branch ready #4052
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 husseinkad on 2026-10-11T22:14:35Z.
scePthreadJointhrowsstd::runtime_error(which ends the process) when a joinable thread joins itself, andscePthreadJoinandscePthreadDetachthrow the same way on a null thread. FreeBSD 11.4 libthr returnsEDEADLKfor a self-join (join_common) andEINVALfor a null thread in both calls (_pthread_detach). A guest that probes these calls for an error code is terminated instead.Fix branch: https://github.com/husseinkad/AnyPS5/tree/fix/libkernel-join-self-edeadlk (one commit on current main,
Pthread/src/Thread.cppandtests/GuestThreadSelf.cpp).Changed return values versus main (each was a thrown
std::runtime_error):scePthreadJoin(null)andpthread_join(null)now returnEINVAL;scePthreadDetach(null)andpthread_detach(null)now returnEINVAL;scePthreadJoin(self)on a created joinable thread now returnsEDEADLK(11 for POSIX). Callers (JobManager,Ult,Ampr) all compare against 0, andToErrnomapsEDEADLKto 11.Checks:
guest_thread_selfcases fail on main (abort) and pass with the change;guest_ampr_threadsandguest_pthread_cancelpass.check_conventions.pyis clean andpr_overlap.pyfinds no overlap.Not fixed here: the check order differs from FreeBSD, which tests null, then self (
EDEADLK), then detached (EINVAL). Here the detached check runs first, so a self-join on a created detached thread or on the adopted main thread still returnsEINVAL(an existing test asserts that for the main thread); a join afterscePthreadDetach(self)also returnsEINVAL. Joining an already joined thread aborts with "handle invalid" and concurrent joins double-release, where FreeBSD returnsESRCH; both are the same on main. Only Windows was built and run.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T02:07:37Z.
Closing: fixed by #4063.