Commit Graph

8 Commits

Author SHA1 Message Date
Hussein Kadhim 351ca3bb12 fix(libkernel): return EDEADLK for a thread joining itself and EINVAL for a null thread
scePthreadJoin threw when a joinable thread joined itself and
scePthreadJoin and scePthreadDetach threw on a null thread, so
pthread_join and pthread_detach ended the process where FreeBSD libthr
returns EDEADLK and EINVAL.
2026-10-11 22:23:16 +00:00
Hannah Lyons 2741e96172 feat(libkernel): implement pthread_getthreadid_np 2026-10-11 06:38:14 -04:00
Scott Schuster ce98a61a83 feat(libkernel): implement pthread_set_name_np
pthread_set_name_np renames through scePthreadRename; a null name clears it,
as in FreeBSD.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 15:41:36 -05:00
EdouardSence 94409c9f32 fix(libkernel): keep the thread id 64-bit on every host
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 09:58:05 +02:00
EdouardSence 9ba1b06a4e fix(libkernel): start the pthread object with the thread id
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 09:58:05 +02:00
Adrià ab9437e34d
feat(libkernel): implement scePthreadTestcancel and pthread_testcancel (#834) 2026-10-07 11:43:32 +13:00
Merijn fd37c58391 fix(libkernel): report the stack of adopted threads
scePthreadAttrGet reported a null stack address and a zero size for an
adopted thread (the main thread), and for every guest thread on Linux,
where the stack range was never recorded. A garbage collector that scans
thread stacks through scePthreadAttrGetstackaddr and
scePthreadAttrGetstacksize (Unity IL2CPP in PPSA12544) then skipped the
main thread's stack and freed objects it still referenced. The range now
comes from the host thread: GetCurrentThreadStackLimits on Windows,
pthread_getattr_np on Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 23:00:41 +02:00
QDarkRex 76b7f998f5 fix(kernel): give every thread a pthread handle and keep mutex ownership consistent
- scePthreadSelf returned null on Linux and for threads not created by
  scePthreadCreate (including the main thread); such threads now get a
  lazily adopted, non-joinable handle
- scePthreadExit on Linux skipped FinishThread, losing the join value
- detached threads on Linux were never freed; use the reference count
  already used on Windows
- unlocking a recursive mutex from a non-owner was undefined behaviour;
  return SCE_KERNEL_ERROR_EPERM
- scePthreadCondTimedwait did not restore the mutex owner after waking,
  so another thread locking during the wait made the waiter's unlock
  fail with EPERM and left the mutex locked forever
- SCE_KERNEL_ERROR_ETIMEDOUT in Cond.cpp was 0x80020062 instead of 0x8002003C

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 12:38:59 +07:00