fix(libkernel): scePthreadRename returns ENAMETOOLONG for a name of 32 or more characters #17091
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17091"
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 xXPBSXx on 2026-11-08T09:57:00Z.
What
scePthreadRenameset any name on the thread, however long. On a PS5 a name of 40 characters returnsSCE_KERNEL_ERROR_ENAMETOOLONG(0x8002003f, errno 63), while a name of 11 characters and an empty name return 0. This returnsENAMETOOLONGfor a name of 32 or more bytes and leaves the thread's name as it was. A later probe run measured the limit onscePthreadRenameitself, after a 20 character name: names of 5 and 31 characters are accepted, names of 32, 33, 40 and 64 characters returnENAMETOOLONGand the old name is kept, not cut to 31 characters. Whether it refuses before or after it looks up the thread is not measured. A test pins 32 and 40 characters and checks that the stored name stays, and the debt entry indocs/dev/debt/libkernel.mdstates the measurement. A title process was not measured.A review point (gabichuuuuu) led to three follow-up commits:
pthread_set_name_npignored the result ofscePthreadRename, so a name of 32 or more bytes left the old name and set noerrno. It now setserrnofrom the result of the rename. The same run measuredpthread_set_name_npon the payload process: names of 32, 33, 40 and 64 characters seterrno63 (ENAMETOOLONG) and keep the old name. A null name forscePthreadRenamereturned 0 and left an empty name in an earlier run, where this returnsEINVAL; that is not changed here and is recorded in the debt entry.Tested
Measured on a PS5 with firmware 11.60 (
kernel_get_fw_version0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr), on 2026-11-08 at 03:58 UTC. A title process may differ. The calls renamed the probe's own thread; the cases are 1.3, 1.6 and 1.8, lines 6, 9 and 11 of the raw output in the first comment.mainbeforescePthreadRename(self, name of 11 characters)scePthreadRename(self, name of 40 characters)scePthreadRename(self, empty name)Second run, for the follow-up and for the limit: on 2026-11-08 at 19:54 UTC, the same kind of payload process (firmware 11.60). The probe's own main thread was named with 20 times
Z, then renamed with a request of 5, 31, 32, 33, 40 or 64 letters (an alphabet), and the name was read back withpthread_getname_npandscePthreadGetname; the cases are 2.1 to 3.6 of its raw output in the second comment.scePthreadRename(self, request of 5 or 31 characters)scePthreadRename(self, request of 32, 33, 40 or 64 characters)pthread_set_name_np(self, request of 5 or 31 characters)errno0, the name reads back as the request (2.1, 2.2)pthread_set_name_np(self, request of 32, 33, 40 or 64 characters)errno63, the old name stays (2.3-2.6)errno63, the old name staysWith only the follow-up test commit
guest_pthread_renamefails in 3 of 3 runs and with the follow-up fix it passes in 3 of 3 runs (Linux, WSL, Release, on8efd096c0aea). On this branch, Linux (WSL, Release) onmaine6108f3d8e11: with only the test commit the pthread rename test fails in 3 of 3 runs, and with the fix it passes in 3 of 3 runs.tools/check_conventions.py --base upstream/mainpasses on head261bdf1caa80. The probe source and its raw output are in the first comment. Not tested: Windows, macOS, the CI runner, a title process and any other firmware.Overlap (P2, 2026-11-08, list of open pull requests from 22:41 UTC,
main22ae9a397d, checked 22:41-22:46 UTC, head261bdf1caa80): of the 112 open pull requests that changecore/libs/prx/libkernel/Pthread/Posix/Thread.cpp,core/libs/prx/libkernel/Pthread/src/Thread.cpp,core/libs/tests/GuestPthreadRename.cppordocs/dev/debt/libkernel.md, each was merged with and without this branch. #15567 (fail pthread_rename_np and scePthreadRename with EFAULT on an unreadable name) conflicts only with this branch, incore/libs/prx/libkernel/Pthread/src/Thread.cpp, where both change the name handling ofscePthreadRename; it merges withmainnow, so whichever lands second needs a rebase. 42 conflict withmainwithout this branch as well; the other 69 merge cleanly with and without it.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T16:42:27Z.
Review: COMMENTED
Windows run of head
8efd096c0a, merged ontomain828e44310e. To save builds, this ran in one local tree together with 13 other open PRs that touch different files. All 14 merged cleanly. Setup: Windows 11, WinLibs GCC 15.2 (x86_64-ucrt-posix-seh), Release,BUILD_TESTING=ON.guest_pthread_renamewith--repeat until-fail:10: 10 / 10 pass.main'slibkernel/Pthread/src/Thread.cppand this PR's test: 5 / 5 runs fail. With the PR's file put back, it passes again.pthread_set_name_npnow drops long names silently. It callsscePthreadRename(thread, name)and ignores the result (Pthread/Posix/Thread.cpp:452-453). Onmain, a name of 32 or more characters was stored. With this PR it getsENAMETOOLONGand the thread keeps its old name, with nothing reported to the caller. FreeBSD'spthread_set_name_npgoes throughthr_set_name, which truncates a long name and succeeds. The PS5 behaviour ofpthread_set_name_npwasn't measured. Truncating to 31 characters there, or recording the open question in the debt entry, would keep this from becoming a silent no-op.