fix(libkernel): answer pthread_getname_np for a joined thread with ESRCH #4533
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4533"
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 Roojool on 2026-10-12T14:53:10Z.
What
pthread_getname_npon a thread that has already been joined returnsESRCH(3) and leaves the output buffer untouched, as measured on a PS5 (firmware 13.60) and recorded in TechnicalDebt by the entry's author: "a thread that has already been joined returnsESRCH(3) on a PS5 (firmware 13.60)". Before, the freed object could not be told apart from a live thread, so its name was read as for a live one.Depends on: #4481 — that change keeps a joined thread's object alive in a JOINED state, which is what makes the console's answer implementable here at all. This PR is the small follow-up it enables:
pthread_getname_np_nid_postfixreturns the posixESRCH(the sameGUEST_ESRCHit already answers for a null thread) when the thread is already joined; the output buffer is not written.EFAULTfirst; the console table does not measure that order (noted in TechnicalDebt).scePthreadGetnamehas no measured joined-thread behaviour and still reads the retained object's name; unchanged and pinned in the test.Tested
c3faf114eon #4481a2dfbfd34/maind53960612; debt entry moved todocs/dev/debt/libkernel.md. Eight focused tests (guest_pthread_getname,guest_pthread_second_join,guest_pthread_join_self,guest_thread_self,guest_pthread_start,guest_pthread_rename,guest_filesystem,guest_dup) pass on native Windows and WSL Linux after rebuilding; conventions and whitespace checks pass. Full suite was not re-run for this restack.guest_pthread_getname: create a named thread ->scePthreadJoin0 ->pthread_getname_npreturns 3 with a0xAAsentinel buffer untouched ->scePthreadGetnamepinned to today's behaviour (0, retained name); all previous cases kept.dc30882e1): the extended test fails 3/3 on Windows (returns 0 and reads the retained name; abort0xc0000409).guest_pthread_second_join,guest_pthread_join_self,guest_thread_self,guest_pthread_start,guest_pthread_renamepass, and a 21-test pthread/thread sweep passes; WSL2 Linux (g++ 15.2.0, Release) extended test and 6 neighbors pass.python tools/check_conventions.py --base dc30882e1passes (re-run at the final commit).Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryConsole semantics are the TechnicalDebt entry author's PS5 firmware 13.60 measurements (merged #1798's table); no console was run for this change.
Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-12T14:53:18Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-12T16:33:38Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T17:05:55Z.
Windows test: head
52416455cmerged onto currentmain2a5eca11c(clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release,-j2: full build 0 errors; ctest with the filterguest_pthread_getname|guest_pthread_second_join: guest_pthread_getname passed, guest_pthread_second_join passed (2 test(s), 0 failed);python tools/check_conventions.py --base upstream/mainpassed. I did not run the new tests againstmainwithout the change.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-12T20:24:08Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-14T05:35:13Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Imported from boykopovar/AnyPS5. Originally posted by Roojool on 2026-10-15T05:19:12Z.
Thanks for the independent Windows run — full build clean, both tests green, conventions green on the same head. That validation is on the record now.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:06:38Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libkernel/Pthread/include/Pthread.hppL142core/libs/prx/libkernel/Pthread/src/Thread.cppL792-793, L811-812docs/dev/debt/libkernel.mdL146Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libkernel/Pthread/src/Thread.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/Pthread/include/Pthread.hppcore/libs/prx/libkernel/Pthread/src/Thread.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtcore/libs/tests/GuestPthreadGetname.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/Pthread/include/Pthread.hppcore/libs/prx/libkernel/Pthread/src/Thread.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Pthread/Posix/Thread.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Pthread/src/Thread.cpp