Skip to content

fix(libkernel): return EINVAL from the scePthreadAttr stack and guard size calls - #7026

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
milescoviello:fix/pthread-attr-stack-einval
Oct 17, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
milescoviello:fix/pthread-attr-stack-einval

Conversation

@milescoviello

@milescoviello milescoviello commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What

Six scePthreadAttr calls threw std::runtime_error for arguments that FreeBSD's libthr rejects with EINVAL:

Call Threw for libthr (FreeBSD 11)
scePthreadAttrGetstack null attribute, address or size pointer _pthread_attr_getstack
scePthreadAttrGetstackaddr null attribute or address pointer _pthread_attr_getstackaddr
scePthreadAttrGetguardsize null attribute or size pointer _pthread_attr_getguardsize
scePthreadAttrSetguardsize null attribute _pthread_attr_setguardsize
scePthreadAttrSetstack null attribute or address, or a size below the minimum _pthread_attr_setstack
scePthreadAttrSetstackaddr null attribute or address _pthread_attr_setstackaddr

They now return SCE_KERNEL_ERROR_EINVAL (0x80020016) and leave the attribute unchanged. The other scePthreadAttr calls in Attr.cpp already do this, and so do the pthread_attr_* wrappers in Posix/Attr.cpp. The stack minimum stays 16 KiB, the one scePthreadAttrSetstacksize and pthread_attr_setstack use here.

I don't know of a title that hits this. I found it while going through the argument throws in libkernel.

Tested

Ubuntu 24.04, GCC 13.3, Release, on main 6a32550.

Not checked: macOS, a console.

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 under Silent stubs in their library's technical debt file
  • 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
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

… size calls

scePthreadAttrGetstack, Getstackaddr, Getguardsize, Setguardsize,
Setstack and Setstackaddr threw for a null attribute, a null pointer
argument or a stack below the 16 KiB minimum. FreeBSD's libthr returns
EINVAL for those, as the pthread_attr_* wrappers here and the other
scePthreadAttr calls already do.

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

Copy link
Copy Markdown

Some 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.

Pull request Shared files not compared
PR 4972 core/libs/prx/libkernel/CMakeLists.txt
PR 5021 core/libs/prx/libkernel/CMakeLists.txt
PR 6044 core/libs/prx/libkernel/CMakeLists.txt
PR 6222 core/libs/prx/libkernel/CMakeLists.txt
PR 6287 core/libs/prx/libkernel/CMakeLists.txt
PR 6487 core/libs/prx/libkernel/CMakeLists.txt
PR 6884 core/libs/prx/libkernel/CMakeLists.txt

@screamm

screamm commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Windows cross-validation of the whole series (stacked on main 5f61879) is in #7023 (comment): this PR's test passes 3/3, and with only this PR's source reverted it fails with main's throw. Suite, conventions and two title runs show no regression.

Written with Claude Code assistance (validation by a subagent, reviewed in this session).

@oneandonlydean
oneandonlydean merged commit a08bdcb into boykopovar:main Oct 17, 2026
10 checks passed
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.

3 participants