fix(libkernel): join the calling thread and create from an unset attribute as the console does #4160

Merged
hugodearaujo merged 1 commit from upstream-pr/4160 into main 2026-10-12 08:42:14 +00:00
hugodearaujo commented 2026-10-12 00:13:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-12T00:13:41Z.


What

scePthreadJoin threw when a thread joined itself, and scePthreadCreate threw on a zeroed attribute. I called the console's exports from a homebrew payload on a PS5 (firmware 13.60):

Call Console main
scePthreadJoin on the calling thread (a created thread, and the payload's main thread) EDEADLK (0x8002000B) throws
scePthreadCreate with a zeroed attribute 0, a thread with the default attributes throws
scePthreadJoin on a thread created detached, or after scePthreadDetach EINVAL EINVAL
scePthreadDetach twice EINVAL EINVAL
scePthreadJoin a second time ESRCH (0x80020003) reads freed memory

The first two now behave as on the console, and pthread_join on the calling thread returns 11 (EDEADLK). The second join is not changed here: a joined thread is released at once, and keeping it for the second answer needs the thread lifetime to change. A null entry crashed the payload and still throws. A new TechnicalDebt entry records both.

Titles: Hollow Knight: Silksong (PPSA12544), Hades (PPSA03355) and Propagation: Paradise Hotel (PPSA15878) create and join their threads through these calls. None of them is known to join itself or pass a zeroed attribute; this replaces two host exceptions with the console's answers.

Tested

  • PS5 firmware 13.60: the table above.
  • Linux: full CTest 916/916. The new guest_pthread_join_self joins a thread with itself through both APIs and creates one from a zeroed attribute; it aborts on main.
  • Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: 916/918, guest_pthread_join_self passes. agc_write_tracking and guest_kernel_stack_protect fail the same way on current main in this VM.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4823433300 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4160). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-12T00:13:41Z. --- ### What `scePthreadJoin` threw when a thread joined itself, and `scePthreadCreate` threw on a zeroed attribute. I called the console's exports from a homebrew payload on a PS5 (firmware 13.60): | Call | Console | `main` | |---|---|---| | `scePthreadJoin` on the calling thread (a created thread, and the payload's main thread) | **`EDEADLK`** (`0x8002000B`) | throws | | `scePthreadCreate` with a zeroed attribute | **0**, a thread with the default attributes | throws | | `scePthreadJoin` on a thread created detached, or after `scePthreadDetach` | `EINVAL` | `EINVAL` | | `scePthreadDetach` twice | `EINVAL` | `EINVAL` | | `scePthreadJoin` a second time | `ESRCH` (`0x80020003`) | reads freed memory | The first two now behave as on the console, and `pthread_join` on the calling thread returns 11 (`EDEADLK`). The second join is not changed here: a joined thread is released at once, and keeping it for the second answer needs the thread lifetime to change. A null entry crashed the payload and still throws. A new TechnicalDebt entry records both. Titles: Hollow Knight: Silksong (PPSA12544), Hades (PPSA03355) and Propagation: Paradise Hotel (PPSA15878) create and join their threads through these calls. None of them is known to join itself or pass a zeroed attribute; this replaces two host exceptions with the console's answers. ### Tested - PS5 firmware 13.60: the table above. - Linux: full CTest 916/916. The new `guest_pthread_join_self` joins a thread with itself through both APIs and creates one from a zeroed attribute; it aborts on `main`. - Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: 916/918, `guest_pthread_join_self` passes. `agc_write_tracking` and `guest_kernel_stack_protect` fail the same way on current `main` in this VM. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4160
No description provided.