Skip to content

fix(libkernel): return ENOTSUP from pthread_attr_setschedparam and setschedpolicy like libthr - #7028

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

oneandonlydean merged 1 commit into
boykopovar:mainfrom
milescoviello:fix/pthread-attr-sched-enotsup

Conversation

@milescoviello

@milescoviello milescoviello commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What

pthread_attr_setschedparam and pthread_attr_setschedpolicy accepted values that FreeBSD's libthr rejects:

  • _pthread_attr_setschedparam returns ENOTSUP for a null sched_param, and under SCHED_FIFO or SCHED_RR for a priority outside the policy's range. It accepts any priority under SCHED_OTHER. The wrapper returned EINVAL for the null pointer and stored any priority.
  • _pthread_attr_setschedpolicy returns ENOTSUP for a policy outside SCHED_FIFO..SCHED_RR (1..3). The wrapper stored any policy.

Both now return ENOTSUP (45) in those cases and leave the attribute unchanged. The priority range is the one sched_get_priority_min and sched_get_priority_max report here for FIFO and RR (256..767), and scePthreadAttrSetschedparam uses the same range.

Not changed: libthr's setschedpolicy also resets the priority to the policy's default, and this wrapper still keeps the previous priority. The SCHED_OTHER default on the console isn't known to me.

I don't know of a title that hits this. I found it while comparing the pthread_attr wrappers with libthr.

Tested

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

  • guest_pthread_attr: new CheckSchedArguments. A null parameter gives ENOTSUP. Under FIFO and RR, priorities 0, 1, 255, 768 and 1000 give ENOTSUP and the stored priority is kept, while 256 and 767 are accepted. Under SCHED_OTHER, 1000 is accepted. Policies -1, 0, 4 and 100 give ENOTSUP and the policy is kept. A null or unset attribute still gives EINVAL. With main's Posix/Attr.cpp the test aborts at the null-parameter check (EINVAL instead of ENOTSUP). With this change it passes 3 of 3.
  • ctest -R '^guest_|libc': 403 of 403 pass, with this and my other small libkernel argument fixes from today applied together.
  • tools/check_conventions.py passes. tools/pr_overlap.py finds no conflicting lines. It couldn't compare against test: organize library tests and label CTest suites #6044 (it conflicts with main), which moves the test files.
  • Windows 11 Pro, Ryzen 7 5700X, WinLibs GCC 15.2.0 r7, Release, with the ten PRs of this series merged in order: this PR's test passes 3 of 3, and with only this PR's source reverted it fails with main's behaviour. (series run by @screamm)

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

…tschedpolicy like libthr

FreeBSD's libthr rejects a null sched_param and, under SCHED_FIFO or
SCHED_RR, a priority outside sched_get_priority_min..max with ENOTSUP,
and a policy outside SCHED_FIFO..SCHED_RR with ENOTSUP. The wrappers
returned EINVAL for the null parameter and stored any priority or
policy.

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 6044 core/libs/tests/GuestPthreadAttr.cpp

@screamm

screamm commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Windows run in #7023 (comment): guest_pthread_attr 3/3, and the negative control fails as described. This is the only PR in the series that rejects input main accepted. RetroArch PPSA99169 calls setschedpolicy(1) and then setschedparam(700), which is inside 256..767 and accepted. The range is this project's, not verified on a console.

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

@milescoviello

Copy link
Copy Markdown
Contributor Author

Thanks for checking the callers, @screamm. Yes, this is the one PR in the series that refuses input main took. The 256..767 range is what sched_get_priority_min and sched_get_priority_max return here, which are this project's values, not a console measurement. I'm glad RetroArch's setschedpolicy(1) then setschedparam(700) stays inside it.

AI-assisted: yes (Claude Code)

@oneandonlydean oneandonlydean self-assigned this Oct 17, 2026
@oneandonlydean
oneandonlydean merged commit c0b37ca 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