feat(libkernel): implement pthread_set_name_np #3031

Merged
TheAggie merged 1 commit from upstream-pr/3031 into main 2026-10-11 05:40:30 +00:00
TheAggie commented 2026-10-10 20:49:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T20:49:09Z.


What

pthread_set_name_np (oxMp8uPqa+U) isn't exported, and six catalog homebrew titles stop on it at start-up on main:

FAIL: unresolved ELF import oxMp8uPqa+U from libkernel.prx

It renames through the existing scePthreadRename. A null name clears the name, as in FreeBSD. Like FreeBSD's version it returns nothing, so a failure (for example a null thread) is ignored.

Test (guest_thread_self): the main thread's name reads back through scePthreadGetname after a rename, is empty after a null name, and a null thread does nothing.

This is #1872 again, which was closed while no title reached it on main yet. It's now the next stop for these titles.

Tested

Title stops. Each release ZIP was checked against its catalog sha256, relinked with relinker --windows --registry, and run for 20 s.

Title main b8a083b2 with this PR
ScreenTester5 (PPSA69420) oxMp8uPqa+U (pthread_set_name_np) still running at 20 s
Yamagi Quake II (PPSA99007) oxMp8uPqa+U gets past it, then exits with code 0 right after start (most likely because the Quake II game data isn't installed; not checked)
EVO Player (PPSA99039) oxMp8uPqa+U n1KOc0lTUEs (arc4random_buf, #2865)
PS5VR (PPSA99177) oxMp8uPqa+U Jb2uGFMr688 (pthread_getaffinity_np)
Jelly5 (PPSA99505) oxMp8uPqa+U -nvxBWa0iDs (gethostname, #2968)
Emby5 (PPSA99515) oxMp8uPqa+U -nvxBWa0iDs (gethostname, #2968)

Tests:

  • pthread|thread|kernel tests: 25 of 25 pass.
  • tools/check_conventions.py passes.

Setup: Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Not tested on Linux or macOS. @babyhuey checked the same change on Linux in #1872.

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 (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4814338237 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3031). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-10T20:49:09Z. --- ### What `pthread_set_name_np` (`oxMp8uPqa+U`) isn't exported, and six catalog homebrew titles stop on it at start-up on `main`: ``` FAIL: unresolved ELF import oxMp8uPqa+U from libkernel.prx ``` It renames through the existing `scePthreadRename`. A null name clears the name, as in FreeBSD. Like FreeBSD's version it returns nothing, so a failure (for example a null thread) is ignored. Test (`guest_thread_self`): the main thread's name reads back through `scePthreadGetname` after a rename, is empty after a null name, and a null thread does nothing. This is #1872 again, which was closed while no title reached it on `main` yet. It's now the next stop for these titles. ### Tested **Title stops.** Each release ZIP was checked against its catalog sha256, relinked with `relinker --windows --registry`, and run for 20 s. | Title | `main` b8a083b2 | with this PR | |---|---|---| | ScreenTester5 (PPSA69420) | `oxMp8uPqa+U` (`pthread_set_name_np`) | still running at 20 s | | Yamagi Quake II (PPSA99007) | `oxMp8uPqa+U` | gets past it, then exits with code 0 right after start (most likely because the Quake II game data isn't installed; not checked) | | EVO Player (PPSA99039) | `oxMp8uPqa+U` | `n1KOc0lTUEs` (`arc4random_buf`, #2865) | | PS5VR (PPSA99177) | `oxMp8uPqa+U` | `Jb2uGFMr688` (`pthread_getaffinity_np`) | | Jelly5 (PPSA99505) | `oxMp8uPqa+U` | `-nvxBWa0iDs` (`gethostname`, #2968) | | Emby5 (PPSA99515) | `oxMp8uPqa+U` | `-nvxBWa0iDs` (`gethostname`, #2968) | **Tests:** - `pthread|thread|kernel` tests: 25 of 25 pass. - `tools/check_conventions.py` passes. **Setup:** Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Not tested on Linux or macOS. @babyhuey checked the same change on Linux in #1872. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-10 20:49:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T20:49:31Z.


Progress report (262c031 → ce98a61)

➖ System libraries: 84.44% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel pthread_set_name_np_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102033906 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3031#issuecomment-6102033906). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T20:49:31Z. --- <!-- progress-report --> ### Progress report (262c031 → ce98a61) ➖ **System libraries**: 84.44% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `pthread_set_name_np_nid_postfix` | </details>
babyhuey commented 2026-10-10 22:16:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T22:16:14Z.


Linux check, since the runs above are Windows: ce98a61a merged onto main (clean), Ubuntu 24.04, GCC 13, Release, catalog builds with sce_module/libc.prx unwrapped (#2605).

  • guest_thread_self passes 5/5 (--repeat until-fail:5).
  • Every title that stops at oxMp8uPqa+U on main gets past it:
Title with this PR (Linux)
ScreenTester5 (PPSA69420) no missing import; runs until DisplayWindow finds no Vulkan display in the headless test container
Yamagi Quake II (PPSA99007) still running after 30 s
PS5VR (PPSA99177) iA-DdobUen8 (scePadVrControllerReadState); Windows reports Jb2uGFMr688 first
Jelly5 (PPSA99505), Emby5 (PPSA99515) -nvxBWa0iDs (gethostname, #2968)
OpenNOW (PPSA99082), on main ecafb64f with pthread_rwlockattr_init in 04AjkP0jO9U (_umtx_op, #1482)
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102758586 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3031#issuecomment-6102758586). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T22:16:14Z. --- Linux check, since the runs above are Windows: ce98a61a merged onto `main` (clean), Ubuntu 24.04, GCC 13, Release, catalog builds with `sce_module/libc.prx` unwrapped (#2605). - `guest_thread_self` passes 5/5 (`--repeat until-fail:5`). - Every title that stops at `oxMp8uPqa+U` on `main` gets past it: | Title | with this PR (Linux) | |---|---| | ScreenTester5 (PPSA69420) | no missing import; runs until `DisplayWindow` finds no Vulkan display in the headless test container | | Yamagi Quake II (PPSA99007) | still running after 30 s | | PS5VR (PPSA99177) | `iA-DdobUen8` (`scePadVrControllerReadState`); Windows reports `Jb2uGFMr688` first | | Jelly5 (PPSA99505), Emby5 (PPSA99515) | `-nvxBWa0iDs` (`gethostname`, #2968) | | OpenNOW (PPSA99082), on `main` ecafb64f with `pthread_rwlockattr_init` in | `04AjkP0jO9U` (`_umtx_op`, #1482) |
Dextroid17 commented 2026-10-10 23:57:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-10T23:57:49Z.

Review: COMMENTED


This is the ideal shape for a resubmission: the same function as #1872, which was closed precisely because no title reached it — and now six do, with a table that shows it.

The evidence is what this tree asks for, and then a little more. A named title list, the exact FAIL: unresolved ELF import … from libkernel.prx line, each release ZIP checked against its catalog checksum, relinked, and run for twenty seconds — that answers the acceptance bar for six titles at once, and "still running at 20 s" is exactly the right measurement for a start-up import. The Quake II row saying the exit is most likely missing game data, and that it was not checked, is the honesty that makes the rest of the table worth trusting.

The implementation is the shape it should be. Renaming through the existing scePthreadRename reuses the code that already does this, clearing the name on a null pointer matches FreeBSD, and returning void so a failure is ignored is FreeBSD's behaviour too — which is what a name setter wants, since there is nothing a caller could usefully do with the error. (scePthreadRename returns EINVAL for a null thread rather than throwing, so the discard is clean.) Of the test's three calls, the read-back and the clear are asserted; the null-thread call is exercised without an assertion, enough to show it does not crash but not what it returns.

One question about limits, and the numbers are worth stating exactly. Linux truncates a thread name to 16 bytes silently; FreeBSD's thr_set_name truncates to MAXCOMLEN + 1, which is 20. In this tree the write is unbounded while the read-back is cut to THREAD_NAME_CAPACITY - 1, 31 bytes — so a name longer than the console allows is stored in full and read back shortened, rather than refused. Is the console's own limit known, or is that a line for the entry? It is the one place a very long name behaves differently.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5481251336 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3031#pullrequestreview-5481251336). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-10T23:57:49Z. **Review:** COMMENTED --- This is the ideal shape for a resubmission: the same function as #1872, which was closed precisely because no title reached it — and now six do, with a table that shows it. **The evidence is what this tree asks for, and then a little more.** A named title list, the exact `FAIL: unresolved ELF import … from libkernel.prx` line, each release ZIP checked against its catalog checksum, relinked, and run for twenty seconds — that answers the acceptance bar for six titles at once, and "still running at 20 s" is exactly the right measurement for a start-up import. The Quake II row saying the exit is most likely missing game data, and that it was not checked, is the honesty that makes the rest of the table worth trusting. **The implementation is the shape it should be.** Renaming through the existing `scePthreadRename` reuses the code that already does this, clearing the name on a null pointer matches FreeBSD, and returning `void` so a failure is ignored is FreeBSD's behaviour too — which is what a name setter wants, since there is nothing a caller could usefully do with the error. (`scePthreadRename` returns `EINVAL` for a null thread rather than throwing, so the discard is clean.) Of the test's three calls, the read-back and the clear are asserted; the null-thread call is exercised without an assertion, enough to show it does not crash but not what it returns. **One question about limits, and the numbers are worth stating exactly.** Linux truncates a thread name to 16 bytes silently; FreeBSD's `thr_set_name` truncates to `MAXCOMLEN + 1`, which is 20. In this tree the write is unbounded while the read-back is cut to `THREAD_NAME_CAPACITY - 1`, 31 bytes — so a name longer than the console allows is stored in full and read back shortened, rather than refused. Is the console's own limit known, or is that a line for the entry? It is the one place a very long name behaves differently. Written with AI assistance.
overlordxrz-source commented 2026-10-11 01:26:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by overlordxrz-source on 2026-10-11T01:26:32Z.


More titles that stop at oxMp8uPqa+U on current main and get past it with this PR, on our Linux rig (Ubuntu x86-64, GCC, Release, lavapipe; catalog ZIPs sha256-checked, eboot.bin and sce_module/libc.prx unwrapped). main 4610d586005c38c10bdf81184d42b390feabc2a5, and the same main with eb92042fc2dc06b4c5bfef31bbde1d1d792a465b merged:

Title main with #3031
SwanStationPS5 (PPSA98510) oxMp8uPqa+U (pthread_set_name_np) 5G2ONUzRgjY (memrchr)
PSBox Cloud Gaming (PPSA99810) oxMp8uPqa+U (pthread_set_name_np) ZjtRqSMJwdw (sinh)
PPSA98510: ./app.elf: symbol lookup error: ./app.elf: undefined symbol: 5G2ONUzRgjY
PPSA99810: ./app.elf: symbol lookup error: ./app.elf: undefined symbol: ZjtRqSMJwdw

These add to @babyhuey's table above.

AI-assisted: yes (the write-up; the rig run and its log lines are real).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104182949 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3031#issuecomment-6104182949). Originally posted by [overlordxrz-source](https://github.com/overlordxrz-source) on 2026-10-11T01:26:32Z. --- More titles that stop at `oxMp8uPqa+U` on current `main` and get past it with this PR, on our Linux rig (Ubuntu x86-64, GCC, Release, lavapipe; catalog ZIPs sha256-checked, `eboot.bin` and `sce_module/libc.prx` unwrapped). `main` `4610d586005c38c10bdf81184d42b390feabc2a5`, and the same `main` with `eb92042fc2dc06b4c5bfef31bbde1d1d792a465b` merged: | Title | `main` | with #3031 | |---|---|---| | SwanStationPS5 (PPSA98510) | `oxMp8uPqa+U` (`pthread_set_name_np`) | `5G2ONUzRgjY` (`memrchr`) | | PSBox Cloud Gaming (PPSA99810) | `oxMp8uPqa+U` (`pthread_set_name_np`) | `ZjtRqSMJwdw` (`sinh`) | ``` PPSA98510: ./app.elf: symbol lookup error: ./app.elf: undefined symbol: 5G2ONUzRgjY PPSA99810: ./app.elf: symbol lookup error: ./app.elf: undefined symbol: ZjtRqSMJwdw ``` These add to @babyhuey's table above. AI-assisted: yes (the write-up; the rig run and its log lines are real).
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!3031
No description provided.