fix(libkernel): return EDEADLK for self-join and EINVAL for null threads #4063

Merged
MarcZX10 merged 1 commit from upstream-pr/4063 into main 2026-10-12 12:25:37 +00:00
MarcZX10 commented 2026-10-11 22:27:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T22:27:39Z.


What

Carry Hussein Kadhim’s fix from issue #4052, preserving his implementation commit authorship. Null scePthreadJoin/scePthreadDetach and POSIX pthread_join/pthread_detach calls now return EINVAL; a joinable thread joining itself returns EDEADLK. Regression cases cover the guest and POSIX entry points.

The existing detached-thread check order remains unchanged. As described in the issue, self-join on a detached or adopted main thread still returns EINVAL rather than EDEADLK.

Tested

  • Linux GCC 12.2 Release: built guest_thread_self_tests; CTest guest_thread_self passed (1/1).
  • The issue author reports Windows coverage: guest_thread_self fails on main and passes with the fix; guest_ampr_threads and guest_pthread_cancel pass. I did not run Windows locally.
  • The overlap checker reports no overlap with open PRs. git diff --check passed.

Checklist

  • Based on current main
  • One topic per PR
  • No new third-party code
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4822863940 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4063). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T22:27:39Z. --- ### What Carry Hussein Kadhim’s fix from [issue #4052](https://github.com/boykopovar/AnyPS5/issues/4052), preserving his implementation commit authorship. Null `scePthreadJoin`/`scePthreadDetach` and POSIX `pthread_join`/`pthread_detach` calls now return `EINVAL`; a joinable thread joining itself returns `EDEADLK`. Regression cases cover the guest and POSIX entry points. The existing detached-thread check order remains unchanged. As described in the issue, self-join on a detached or adopted main thread still returns `EINVAL` rather than `EDEADLK`. ### Tested - Linux GCC 12.2 Release: built `guest_thread_self_tests`; CTest `guest_thread_self` passed (1/1). - The issue author reports Windows coverage: `guest_thread_self` fails on main and passes with the fix; `guest_ampr_threads` and `guest_pthread_cancel` pass. I did not run Windows locally. - The overlap checker reports no overlap with open PRs. `git diff --check` passed. ### Checklist - [x] Based on current `main` - [x] One topic per PR - [x] No new third-party code - [x] Depends on: none - [x] AI-assisted: yes
MarcZX10 commented 2026-10-11 22:27:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T22:27:45Z.


I independently built guest_thread_self_tests with GCC 12.2 in Release on Linux and ran CTest guest_thread_self; it passed (1/1). The open-PR overlap checker found no overlap, and the local conventions and diff checks pass. Windows coverage remains the issue author’s report, not a local run.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114593091 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4063#issuecomment-6114593091). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T22:27:45Z. --- I independently built guest_thread_self_tests with GCC 12.2 in Release on Linux and ran CTest guest_thread_self; it passed (1/1). The open-PR overlap checker found no overlap, and the local conventions and diff checks pass. Windows coverage remains the issue author’s report, not a local run.
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!4063
No description provided.