Skip to content

feat(libkernel): implement pthread_set_name_np - #3031

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
TheAggie:feat/libkernel-pthread-set-name-np
Oct 11, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
TheAggie:feat/libkernel-pthread-set-name-np

Conversation

@TheAggie

Copy link
Copy Markdown
Contributor

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 b8a083b 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

pthread_set_name_np renames through scePthreadRename; a null name clears it,
as in FreeBSD.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Progress report (262c031 → ce98a61)

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

✅ 1 implemented
Library Name
libkernel pthread_set_name_np_nid_postfix

@babyhuey

Copy link
Copy Markdown
Contributor

Linux check, since the runs above are Windows: ce98a61 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 ecafb64 with pthread_rwlockattr_init in 04AjkP0jO9U (_umtx_op, #1482)

@Dextroid17 Dextroid17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants